/* Base Styles and CSS Variables */

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

:root {
    /* Category theme colors (dynamically set by theming.js) */
    --category-primary: #667eea;
    --category-secondary: #764ba2;
    --category-light: #8a9dff;
    --category-dark: #5a3a85;
    --category-background: url('../media/backgrounds/fuji_cherry_blossom.png'); /* Default fallback */

    /* Gradients using category colors */
    --primary-gradient: linear-gradient(135deg, var(--category-primary) 0%, var(--category-secondary) 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --dark-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-bg-dark: rgba(0, 0, 0, 0.3);
    --text-primary: #333;
    --text-secondary: #666;
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Poppins', 'Noto Sans JP', sans-serif;
    min-height: 100vh;  /* Fallback for older browsers */
    min-height: 100dvh; /* Dynamic viewport - excludes Safari address bar */
    background: var(--primary-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-x: hidden;
    position: relative;
    transition: background 0.6s ease, var(--transition);
    padding-top: 2vh;
    padding-bottom: 2vh;
    box-sizing: border-box;
}

body.dark-mode {
    --glass-bg: rgba(255, 255, 255, 0.05);
    --text-primary: #f0f0f0;
    --text-secondary: #aaa;
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, var(--category-dark) 0%, #16213e 100%);
}

/* Image Fade-in Transition */
.img-fade-in {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.img-fade-in.loaded {
    opacity: 1;
}

/* Container */
.container {
    width: 95%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 15px;
    padding-bottom: 5px; /* Reduce bottom padding */
    z-index: 10;
    display: none;
    flex: 1; /* Make container expand to fill available height */
    flex-direction: column;
}

.container.active {
    display: flex;
    animation: slideIn 0.5s ease;
}

/* Top Bar Container */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 10px;
}

/* Header */
.header {
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header h1 {
    font-size: 2.2em;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(90deg, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.88) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 2px;
}

/* Stats Bar */
.stats-bar {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
}

.stat-value {
    font-weight: 700;
    font-size: 1.15em;
}

.stat-label {
    opacity: 0.9;
    font-size: 0.85em;
}

/* New Dashboard Styles */
.stats-dashboard {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 16px 22px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.35);
    min-width: 500px;
    position: relative;
    transition: border-color 0.6s ease;
}

/* Subtle category color tint on stats dashboard */
.stats-dashboard::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--category-primary), var(--category-secondary));
    opacity: 0.08;
    border-radius: 20px;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.stats-today {
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
}

.stat-label-text {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85em;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item-inline {
    color: white;
    font-size: 1em;
    font-weight: 500;
    white-space: nowrap;
}

.stat-item-inline span {
    font-weight: 700;
}

.stats-overall {
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

.overall-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95em;
    margin-bottom: 8px;
    font-weight: 500;
}

.overall-text span {
    font-weight: 700;
}

.overall-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.overall-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80 0%, #22c55e 100%);
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

/* Media status (Total vocabulary count) */
.media-status {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9em;
    margin-top: 5px;
    margin-bottom: 10px;
}

/* Keyboard shortcuts info */
.shortcuts-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 15px;
    color: white;
    font-size: 0.9em;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.shortcuts-info:hover {
    opacity: 1;
}

/* Motivational message */
.motivation {
    text-align: center;
    color: white;
    font-size: 1.2em;
    font-weight: 500;
    margin-top: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.5s ease;
}

/* Category icon (on card badges) */
.category-icon {
    width: 90px;
    height: 90px;
    border-radius: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

/* Base Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.95);
}

/* Common Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 10px;
        padding-bottom: 5px; /* Reduce bottom padding on mobile too */
    }

    .header h1 {
        font-size: 1.8em;
    }
}
