/* style.css */
:root {
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --primary-color: #1a365d; /* Navy */
    --accent-color: #e63946;  /* Light Red Accent */
    --card-bg: #ffffff;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --sidebar-bg: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --border-color: #333333;
    --primary-color: #4facfe;
    --accent-color: #ff6b6b;
    --card-bg: #1e1e1e;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.4);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* Header */
.header {
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

.logo p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.icon-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.icon-toggle:hover {
    background-color: var(--bg-color);
    color: var(--accent-color);
}

.mobile-only {
    display: none;
}

/* App Layout */
.app-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 75px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width, 280px);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    flex-shrink: 0;
    height: calc(100vh - 75px);
    position: sticky;
    top: 75px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease;
}

.sidebar.is-resizing {
    transition: none;
}

.sidebar.collapsed {
    width: 0 !important;
    padding-left: 0;
    padding-right: 0;
    border-right-color: transparent;
}

.resizer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
    background-color: transparent;
    transition: background-color 0.2s;
}

.sidebar.collapsed .resizer {
    display: none;
}

.resizer:hover, .sidebar.is-resizing .resizer {
    background-color: var(--primary-color);
}

.sidebar-title {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lesson-list {
    list-style: none;
}

.lesson-item {
    padding: 0.85rem 1.2rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lesson-item i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.lesson-item:hover {
    background-color: rgba(26, 54, 93, 0.05);
    color: var(--primary-color);
    transform: translateX(4px);
}

[data-theme="dark"] .lesson-item:hover {
    background-color: rgba(79, 172, 254, 0.1);
}

.lesson-item.active {
    background-color: var(--primary-color);
    color: white;
}

.lesson-item.active i {
    color: white;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 2.5rem 3rem;
    overflow-y: auto;
}

.content-header {
    margin-bottom: 2rem;
}

.content-header h2 {
    font-size: 2rem;
    color: var(--primary-color);
    font-weight: 700;
    border-bottom: 3px solid var(--accent-color);
    display: inline-block;
    padding-bottom: 0.5rem;
}

.grammar-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Placeholder */
.placeholder-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-secondary);
    text-align: center;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

/* Grammar Card */
.grammar-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

.grammar-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.gc-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.gc-pattern {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.gc-meaning {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
    flex-grow: 1;
}

.gc-section {
    margin-bottom: 1.5rem;
}

.gc-section-title {
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.gc-usage {
    background-color: rgba(26, 54, 93, 0.03);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
    font-size: 1rem;
}

[data-theme="dark"] .gc-usage {
    background-color: rgba(79, 172, 254, 0.05);
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.example-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ex-jp {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.ex-vi {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.ex-num {
    color: var(--accent-color);
    font-weight: 700;
    margin-right: 0.5rem;
}

/* Animations */
@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100% !important;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1.5rem;
    }
    
    .sidebar.collapsed {
        height: 0 !important;
        padding: 0 1.5rem !important;
        border-bottom: none;
        overflow: hidden;
        opacity: 0;
    }
    
    .resizer {
        display: none !important;
    }
    
    .lesson-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .main-content {
        padding: 1.5rem;
    }
    
    .grammar-card {
        padding: 1.5rem;
    }
    
    .gc-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Export Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

[data-theme="dark"] .btn {
    color: var(--bg-color);
}

.btn:hover {
    background-color: var(--accent-color);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

[data-theme="dark"] .btn-outline {
    color: white;
    border-color: white;
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Print Layout */
#print-area {
    display: none;
}

@media print {
    body {
        background-color: white;
        color: black;
        font-family: serif; 
        /* or keep sans-serif if preferred, but reset variables */
    }
    
    .header, .sidebar, .export-controls, .main-content > *:not(#print-area) {
        display: none !important;
    }
    
    .app-container, .main-content {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
    }
    
    #print-area {
        display: block !important;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .print-lesson {
        margin-bottom: 2rem;
        page-break-after: always;
    }
    
    /* Do not page-break after the very last lesson */
    .print-lesson:last-child {
        page-break-after: auto;
    }
    
    .print-lesson-title {
        font-size: 20pt;
        font-weight: bold;
        margin-bottom: 1.5rem;
        border-bottom: 2px solid #000;
        padding-bottom: 5px;
        text-align: center;
    }

    .print-grammar-item {
        margin-bottom: 2rem;
        page-break-inside: avoid;
    }

    .print-pattern {
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 8px;
        color: #000;
    }

    .print-usage {
        font-size: 11pt;
        margin-bottom: 12px;
        /* Matches requested format */
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 10px;
        page-break-inside: auto;
    }

    .print-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .print-table th, .print-table td {
        border: 1px solid #000;
        padding: 6px 8px;
        text-align: left;
        font-size: 11pt;
    }

    .print-table th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: bold;
    }

    .print-table th.col-no { width: 5%; text-align: center; }
    .print-table th.col-jp { width: 45%; }
    .print-table th.col-vi { width: 50%; }
    .print-table td:first-child { text-align: center; }
}
