/* Base Styles */
:root {
    /* Default theme (light) */
    --primary-color: #4f6df5;
    --primary-dark: #3a56d4;
    --secondary-color: #f9a826;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f5f7ff;
    --card-color: #fff;
    --panel-header: var(--primary-color);
    --panel-text: #fff;
    --input-bg: #fff;
    --input-border: #ddd;
    --stat-bg: #f8f9fc;
    --stat-icon-bg: rgba(79, 109, 245, 0.1);
    --milestone-bg: #e9ecef;
    --milestone-line: #e9ecef;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
}

/* Dark theme */
[data-theme="dark"] {
    --primary-color: #5d7bf7;
    --primary-dark: #4a63d4;
    --secondary-color: #ffb74d;
    --text-color: #e0e0e0;
    --text-light: #aaaaaa;
    --bg-color: #1a1a2e;
    --card-color: #242442;
    --panel-header: #30305a;
    --panel-text: #e0e0e0;
    --input-bg: #2a2a4a;
    --input-border: #3a3a5a;
    --stat-bg: #2a2a4a;
    --stat-icon-bg: rgba(93, 123, 247, 0.2);
    --milestone-bg: #3a3a5a;
    --milestone-line: #3a3a5a;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Blue theme */
[data-color="blue"] {
    --primary-color: #4f6df5;
    --primary-dark: #3a56d4;
    --secondary-color: #f9a826;
}

/* Green theme */
[data-color="green"] {
    --primary-color: #32936f;
    --primary-dark: #2a7a5d;
    --secondary-color: #ffcc29;
}

/* Purple theme */
[data-color="purple"] {
    --primary-color: #9b5de5;
    --primary-dark: #8345c5;
    --secondary-color: #fee440;
}

/* Red theme */
[data-color="red"] {
    --primary-color: #e94560;
    --primary-dark: #d13a52;
    --secondary-color: #16213e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 30px;
}

header h1 {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 2.5rem;
    position: relative;
    display: inline-block;
}

header h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background-color: var(--secondary-color);
    border-radius: 2px;
}

/* App Container */
.app-container {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1200px) {
    .app-container {
        grid-template-columns: 1fr 1fr;
    }
    
    .progress-panel {
        grid-column: span 2;
        order: 3;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .settings-panel, .content-panel, .progress-panel {
        grid-column: 1;
    }
    
    .progress-panel {
        order: 3;
    }
}

/* Panels */
.settings-panel, .content-panel {
    background-color: var(--card-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    height: 100%;
}

.progress-panel {
    background-color: var(--bg-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    height: 100%;
}

.panel-header {
    background-color: var(--panel-header);
    color: var(--panel-text);
    padding: 15px 20px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.panel-header h2 {
    font-weight: 600;
    font-size: 1.2rem;
}

/* Settings Panel */
.settings-content {
    padding: 20px;
}

.setting-group, .toggle-group {
    margin-bottom: 20px;
}

.setting-group label, .toggle-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
}

.input-with-icon input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 1rem;
    transition: var(--transition);
    background-color: var(--input-bg);
    color: var(--text-color);
}

.input-with-icon input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 109, 245, 0.2);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Content Panel */
.textarea-container {
    height: 100%;
    padding: 20px;
}

#essay-content {
    width: 100%;
    height: 400px;
    padding: 15px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    transition: var(--transition);
    background-color: var(--input-bg);
    color: var(--text-color);
}

#essay-content:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 109, 245, 0.2);
}

/* Progress Panel */
/* Stats Dashboard */
.stats-dashboard {
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.stat-metric {
    background-color: var(--stat-bg);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 20px;
    flex: 1;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: visible; /* Changed from hidden to visible */
    min-width: 0; /* Allow proper flexbox shrinking */
}

.stat-metric:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.time-remaining {
    border-top: 3px solid var(--primary-color);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap; /* Allow wrapping if needed */
    width: 100%;
}

.stat-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    margin: 0;
    overflow: visible; /* Ensure text is not cut off */
    white-space: normal; /* Allow text to wrap */
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--stat-icon-bg);
    color: var(--primary-color);
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-icon i {
    font-size: 1.1rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-top: auto;
    line-height: 1.2;
    padding: 5px 0;
    overflow: visible;
}

#completion-percentage {
    font-size: 2.5rem;
    letter-spacing: -0.5px; /* Slightly tighten the spacing for the percentage */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .stats-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    #completion-percentage {
        font-size: 2.2rem;
    }
}

/* Additional media query for very small screens */
@media (max-width: 480px) {
    .stats-dashboard {
        padding: 15px;
    }
    
    .stat-metric {
        padding: 15px;
    }
    
    .stat-header {
        margin-bottom: 10px;
    }
    
    .stat-header h3 {
        font-size: 0.9rem;
        max-width: 100%; /* Ensure full width is available */
    }
}

/* Progress Bar */
.progress-container {
    padding: 10px 20px 20px;
    margin-top: 10px;
    background-color: var(--card-color);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    margin: 0 20px 20px;
}

.progress-bar-container {
    height: 24px;
    background-color: var(--milestone-bg);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    width: 0%;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
}

.progress-labels {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    margin-top: 8px;
}

.progress-label {
    font-size: 1.1rem;
    color: var(--text-color);
}

.separator {
    margin: 0 10px;
    color: var(--text-light);
}

/* Milestones */
.milestone-container {
    padding: 10px 20px 20px;
    background-color: var(--card-color);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin: 0 20px 20px;
    transition: var(--transition);
}

.milestone-header {
    margin-bottom: 20px;
}

.milestone-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    position: relative;
    display: inline-block;
}

.milestone-header h3::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.milestone-progress {
    position: relative;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    height: 60px;
    margin-top: 10px;
}

.milestone-progress:before {
    content: '';
    position: absolute;
    top: 20px;
    left: 10px;
    right: 10px;
    height: 3px;
    background-color: var(--milestone-line);
    z-index: 1;
    border-radius: 1.5px;
}

.milestone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}

.milestone-dot {
    width: 20px;
    height: 20px;
    background-color: var(--milestone-bg);
    border-radius: 50%;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    border: 2px solid var(--milestone-bg);
    box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 79, 109, 245), 0);
}

.milestone.active .milestone-dot {
    background-color: var(--primary-color);
    transform: scale(1.15);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 5px rgba(var(--primary-color-rgb, 79, 109, 245), 0.2);
}

.milestone-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    transition: var(--transition);
}

.milestone.active .milestone-label {
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.complete-animation {
    animation: pulse 1s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }
    
    .panel-header h2 {
        font-size: 1.1rem;
    }
    
    .stat-content p {
        font-size: 1.2rem;
    }
    
    .progress-label {
        font-size: 1rem;
    }
}
