/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --secondary-color: #7b68ee;
    --success-color: #52c41a;
    --danger-color: #ff4d4f;
    --warning-color: #faad14;
    --bg-color: #0a0e27;
    --bg-secondary: #141b2d;
    --bg-tertiary: #1e2742;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --border-color: #2d3748;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

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

/* ===== Header ===== */
header {
    margin-bottom: 30px;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px;
    position: relative;
}

.back-home {
    position: absolute;
    left: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 1px solid var(--border-color);
}

.back-home:hover {
    color: var(--primary-color);
    background: var(--bg-secondary);
    transform: translateX(-2px);
    border-color: var(--primary-color);
}

.back-home svg {
    width: 20px;
    height: 20px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
}

.header-actions {
    position: absolute;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-switcher {
    display: flex;
    align-items: center;
}

.language-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.language-select:hover {
    border-color: var(--primary-color);
}

.language-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* ===== Buttons ===== */
.btn-icon {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

/* ===== Birthday Setup ===== */
.birthday-setup {
    text-align: center;
    max-width: 500px;
    margin: 40px auto;
}

.birthday-setup h2 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.setup-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.birthday-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

/* ===== Input ===== */
.input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.input::placeholder {
    color: var(--text-secondary);
}

/* ===== Info Cards Row ===== */
.info-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.info-card {
    padding: 16px;
}

.info-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.info-card-header a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
}

.info-card-header a:hover {
    text-decoration: underline;
}

.info-card-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.info-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.info-card-value:last-child {
    margin-bottom: 0;
}

/* ===== What's Left Sections ===== */
.whats-left-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.whats-left-column h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.counters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.counter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.counter-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.counter-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.time-passed-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.time-passed-section h4 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.grid-section {
    margin-bottom: 20px;
}

.grid-section:last-child {
    margin-bottom: 0;
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.grid-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== Stage Info ===== */
/* Stage info uses the same structure as "What's Left" sections, so no additional styles needed */

/* ===== Progress Grids ===== */
.progress-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.grid-cell {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.grid-cell:hover {
    transform: scale(1.1);
    z-index: 1;
    position: relative;
}

/* Color gradients for different grid types - unified style */
.grid-cell.past,
.grid-cell.prime-past {
    background: linear-gradient(135deg, #7b68ee, #4a90e2, #00d4ff);
}

.grid-cell.current {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
}

.grid-cell.future,
.grid-cell.prime-future {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

/* ===== Life Progress Section ===== */
.life-progress-section {
    margin-top: 40px;
}

.life-progress-section h2 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    text-align: center;
    color: var(--text-primary);
}

.life-progress-grid {
    margin-bottom: 30px;
}

.life-progress-grid:last-child {
    margin-bottom: 0;
}

.life-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.life-grid-percentage {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.life-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.life-grid-cell {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.life-grid-cell:hover {
    transform: scale(1.2);
    z-index: 1;
    position: relative;
}

/* Life grid color gradients - unified style */
.life-grid-cell.life-past,
.life-grid-cell.prime-past {
    background: linear-gradient(135deg, #7b68ee, #4a90e2, #00d4ff);
}

.life-grid-cell.life-future,
.life-grid-cell.prime-future {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-help {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ===== Erikson Stages Table ===== */
.erikson-stages-table-section {
    margin-top: 40px;
}

.erikson-stages-table-section h2 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    text-align: center;
    color: var(--text-primary);
}

.stages-table-container {
    overflow-x: auto;
}

.stages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.stages-table thead {
    background: var(--bg-tertiary);
}

.stages-table th {
    padding: 16px 12px;
    text-align: left;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.stages-table th:first-child {
    padding-left: 20px;
}

.stages-table th:last-child {
    padding-right: 20px;
}

.stages-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stages-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.stages-table tbody tr.current-stage-row {
    background: rgba(74, 144, 226, 0.1);
    border-left: 3px solid var(--primary-color);
}

.stages-table tbody tr.current-stage-row:hover {
    background: rgba(74, 144, 226, 0.15);
}

.stages-table td {
    padding: 16px 12px;
    color: var(--text-primary);
    vertical-align: top;
}

.stages-table td:first-child {
    padding-left: 20px;
}

.stages-table td:last-child {
    padding-right: 20px;
}

.stage-name-cell {
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.stage-age-cell {
    white-space: nowrap;
    color: var(--text-secondary);
}

.stage-conflict-cell {
    font-weight: 500;
    color: var(--text-primary);
}

.stage-description-cell {
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 500px;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .info-cards-row {
        grid-template-columns: 1fr;
    }
    
    .whats-left-sections {
        grid-template-columns: 1fr;
    }
    
    .grid-cell {
        width: 16px;
        height: 16px;
    }
    
    .life-grid-cell {
        width: 12px;
        height: 12px;
    }
    
    .header-top {
        flex-direction: column;
    }
    
    .back-home {
        position: relative;
        margin-bottom: 10px;
    }
    
    .header-actions {
        position: relative;
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .grid-cell {
        width: 14px;
        height: 14px;
    }
    
    .life-grid-cell {
        width: 10px;
        height: 10px;
    }
    
    .birthday-input-group {
        flex-direction: column;
    }
    
    .birthday-input-group .input {
        width: 100%;
    }
    
    .stages-table {
        font-size: 0.85rem;
    }
    
    .stages-table th,
    .stages-table td {
        padding: 12px 8px;
    }
    
    .stages-table th:first-child,
    .stages-table td:first-child {
        padding-left: 12px;
    }
    
    .stages-table th:last-child,
    .stages-table td:last-child {
        padding-right: 12px;
    }
    
    .stage-description-cell {
        max-width: 200px;
        font-size: 0.8rem;
    }
}

