@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary-color: #9D2933; /* Japanese Carmine */
    --primary-hover: #7E2129;
    --primary-light: #fbecec;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #f43f5e;
    --danger-hover: #e11d48;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 2rem;
}

/* Soothing Mode (Dark Theme) */
body.night-light {
    --bg-color: #0b1120;
    --surface-color: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #ffffff; /* Red removed, replaced with clean white */
    --primary-hover: #f1f5f9;
    --primary-light: rgba(255, 255, 255, 0.1);
    --danger-color: #fb7185;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.8);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.8);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.8);
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}



body.night-light .navbar {
    background: rgba(15, 23, 42, 0.8);
    border-bottom-color: var(--border-color);
}

body.night-light .card, 
body.night-light .chapter-card, 
body.night-light .data-item,
body.night-light .search-input {
    background: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.night-light .text-muted {
    color: var(--text-secondary);
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-y: auto !important; /* Ensure scroll is always enabled */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Hero Banner */
.hero-card {
    background: linear-gradient(135deg, #9D2933 0%, #7c1f28 100%);
    color: white;
    text-align: center;
    transition: all 0.3s ease;
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    padding: 4rem 2rem;
}


body.night-light .hero-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

body.night-light .hero-card h1,
body.night-light .hero-card h2,
body.night-light .hero-card p {
    color: var(--text-primary);
}

body.night-light .hero-card .btn {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}



a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; }

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

@media (max-width: 768px) {
    .container { padding: 1rem 1rem; }
}

/* Navbar */
.navbar {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.navbar-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-container {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--primary-color);
}

.brand-subtext {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 500;
    opacity: 0.8;
}

/* Desktop Navigation */
.nav-desktop {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.btn-theme {
    background: var(--bg-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    transition: all 0.2s;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
}

.user-profile img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
}

.nav-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--border-color);
}

.logout-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    color: inherit;
    opacity: 0.8;
    padding: 0;
}
.logout-btn:hover {
    color: var(--danger-color);
}

/* Mobile Navigation */
.nav-mobile-toggle {
    display: none;
    align-items: center;
}

.hamburger {
    background: none;
    font-size: 1.25rem;
    color: var(--text-primary);
    padding: 0.5rem;
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--surface-color);
    padding: 2rem 1.5rem;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
}

.mobile-user-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-user-header img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.user-name {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mobile-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: 0.75rem;
    transition: background 0.2s;
}

.mobile-link:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.logout-btn-mobile {
    color: var(--text-primary);
    width: 100%;
    text-align: left;
    background: none;
    font-size: 1rem;
    cursor: pointer;
    border: none;
}
.logout-btn-mobile:hover {
    color: var(--danger-color);
}

.mobile-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

@media (max-width: 768px) {
    .nav-desktop { display: none; }
    .nav-mobile-toggle { display: flex; }
    
    .navbar-brand .brand-subtext { display: none; }
}

@media (max-width: 480px) {
    .brand-text { font-size: 1.1rem; }
    .navbar-logo { height: 28px; }
}


/* Typography */
.text-jp { font-family: 'Noto Sans JP', sans-serif; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
h1 { font-size: 2rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.75rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-success { background: var(--success-color); color: white; }
.btn-success:hover { background: var(--success-hover); transform: translateY(-1px); }
.btn-danger { background: var(--danger-color); color: white; }
.btn-danger:hover { background: var(--danger-hover); transform: translateY(-1px); }
.btn-outline { border: 2px solid var(--border-color); background: transparent; color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-color); }
.btn-block { width: 100%; }

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }

/* Dashboard Specific */
.hero-card {
    background: linear-gradient(135deg, var(--primary-color), #c53030);
    color: white;
    text-align: center;
    padding: 4rem 2rem;
    border: none;
}
.hero-card h1 { color: white; font-size: 4rem; margin-bottom: 0.5rem; font-weight: 800; }


/* Chapter Grid */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}
.chapter-card {
    display: block;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}
.chapter-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.chapter-card.chapter-done {
    background: #f0fdf4;
    border-color: #86efac;
}
.chapter-card.chapter-done:hover {
    border-color: #4ade80;
}
.chapter-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--bg-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.tab {
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: none;
}
.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Lists */
.data-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.data-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.data-jp {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.data-reading {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* Flashcard Specific */
.flashcard-container {
    perspective: 1000px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flashcard {
    width: 100%;
    max-width: 500px;
    height: 350px;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}
.flashcard-back { transform: rotateY(180deg); }

.fc-word { font-size: 4rem; font-weight: 700; margin-bottom: 1rem; }
.fc-reading { font-size: 1.5rem; color: var(--text-secondary); margin-bottom: 1rem; }
.fc-meaning { font-size: 1.5rem; font-weight: 600; color: var(--primary-color); }

ruby { ruby-align: center; }
rt { font-size: 0.5em; color: var(--text-secondary); }

.action-bar {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 2rem;
}
.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.55);
}
.modal-overlay.is-open {
    display: flex;
}
.modal-card {
    background: var(--surface-color);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    margin: 0 1rem;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.18);
    border: 1px solid var(--border-color);
    position: relative;
}

/* Flashcard Badges */
.badge-new {
    background: #dbeafe;
    color: #1e40af;
}
.badge-learning {
    background: #fef3c7;
    color: #92400e;
}
.badge-graduated {
    background: #d1fae5;
    color: #065f46;
}

/* Modern Pagination & Search Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 1rem;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    font-weight: 600;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.25);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: var(--bg-color);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin: 0 1rem;
    letter-spacing: 0.025em;
}

.search-container {
    position: relative;
    margin-bottom: 2rem;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3.25rem;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--surface-color);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.12);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 1.25rem;
    pointer-events: none;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.data-item {
    animation: fadeInUp 0.4s ease backwards;
}

/* Brand Styling */
.navbar-logo {
    height: 38px; /* Slightly larger for balance */
    width: auto;
    display: block;
}

.brand-text {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.35rem; /* Slightly smaller for stacked layout */
    letter-spacing: -0.05em;
    color: var(--primary-color);
}

.brand-subtext {
    color: var(--text-secondary);
}

body.night-light .brand-text {
    color: var(--text-primary);
}


/* Navbar Responsive Fix */
@media (max-width: 768px) {
    .navbar-content {
        padding: 0.5rem 1rem;
    }
    .navbar-logo { height: 32px; }
    .brand-text { font-size: 1.25rem; }
    .nav-link.kamus-link { display: none; }
    .nav-divider { margin: 0 0.25rem; }
}

/* Dashboard Specifics */
.hero-label { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.1em; }
.hero-count { font-size: 5rem; margin: 0.5rem 0; }
.hero-subtext { font-size: 1.125rem; opacity: 0.9; }

@media (max-width: 768px) {
    .hero-count { font-size: 3.5rem; }
    .hero-subtext { font-size: 1rem; }
}

.btn-study-type, .btn-admin-link {
    background: #ffffff;
    color: #9D2933;
    padding: 0.8rem 1.8rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    font-weight: 700;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-study-type:hover, .btn-admin-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    background: #ffffff;
    color: #9D2933;
}

body.night-light .btn-study-type, 
body.night-light .btn-admin-link,
body.night-light .btn-primary,
body.night-light .chapter-badge {
    background: #f8fafc !important; /* Softer White */
    color: #1e293b !important; /* Softer Dark Blue-Gray */
    border: 1px solid #f8fafc !important;
}

body.night-light .btn-study-type:hover, 
body.night-light .btn-admin-link:hover,
body.night-light .btn-primary:hover {
    background: #ffffff !important;
    color: #1e293b !important;
}

body.night-light .btn-outline {
    border-color: rgba(248, 250, 252, 0.4);
    color: #f8fafc;
}

body.night-light .btn-outline:hover {
    border-color: #ffffff;
    background: rgba(248, 250, 252, 0.1);
}

body.night-light .pagination-btn {
    background: transparent !important;
    border-color: rgba(248, 250, 252, 0.2) !important;
    color: #f8fafc !important;
}

body.night-light .pagination-btn:hover:not(:disabled) {
    background: #f8fafc !important;
    color: #1e293b !important;
}


body.night-light .brand-text,
body.night-light .brand-subtext {
    color: #ffffff;
}




.btn-study-done {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    padding: 0.8rem 1.8rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
    backdrop-filter: blur(5px);
}
