/* Leire Books - Book Subscription App */
:root {
    --bg: #F5F1E8;
    --bg-card: #FFFFFF;
    --bg-dark: #2C2C2C;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --primary: #8B6F4E;
    --primary-hover: #725A3D;
    --accent: #C4956A;
    --border: #E0D9CC;
    --success: #4A7C59;
    --error: #C0392B;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

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

/* Typography */
h1, h2, h3, h4 { font-family: 'Playfair Display', serif; font-weight: 600; line-height: 1.3; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.3rem; }

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container { display: flex; align-items: center; justify-content: space-between; }
.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--text-light); text-decoration: none; font-size: 0.95rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--primary); }
.nav-admin { color: var(--accent) !important; }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; flex-direction: column; gap: 5px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--text); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-sm { padding: 6px 16px; font-size: 0.85rem; }
.btn-lg { padding: 14px 36px; font-size: 1.1rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b3844f; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* Checkbox / Radio grid */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.option-item {
    position: relative;
}
.option-item input { position: absolute; opacity: 0; }
.option-item label {
    display: block;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #fff;
}
.option-item input:checked + label {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

/* Alerts */
.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 0.9rem;
}
.alert-success { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }
.alert-error { background: #fce4e4; color: var(--error); border: 1px solid #f5c6cb; }

/* Hero */
.hero {
    text-align: center;
    padding: 80px 20px;
}
.hero h1 { font-size: 3rem; margin-bottom: 16px; color: var(--bg-dark); }
.hero p { font-size: 1.2rem; color: var(--text-light); max-width: 600px; margin: 0 auto 32px; }

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    padding: 40px 0 60px;
}
.feature-card { text-align: center; padding: 36px 24px; }
.feature-icon { font-size: 2.4rem; margin-bottom: 16px; }
.feature-card h3 { margin-bottom: 10px; }
.feature-card p { color: var(--text-light); font-size: 0.9rem; }

/* Auth pages */
.auth-container {
    max-width: 440px;
    margin: 60px auto;
    padding: 0 20px;
}
.auth-container h1 { text-align: center; margin-bottom: 8px; }
.auth-container .subtitle { text-align: center; color: var(--text-light); margin-bottom: 32px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-light); font-size: 0.9rem; }
.auth-footer a { color: var(--primary); }

/* Dashboard */
.dash-header { padding: 40px 0 20px; }
.dash-header h1 { margin-bottom: 4px; }
.dash-header p { color: var(--text-light); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 24px 0;
}
.stat-card { text-align: center; padding: 24px; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); font-family: 'Playfair Display', serif; }
.stat-label { color: var(--text-light); font-size: 0.85rem; margin-top: 4px; }

/* Book grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    padding: 24px 0 60px;
}
.book-card { overflow: hidden; padding: 0; }
.book-cover {
    width: 100%;
    height: 280px;
    object-fit: cover;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-info { padding: 20px; }
.book-info h3 { margin-bottom: 4px; font-size: 1.1rem; }
.book-info .author { color: var(--text-light); font-size: 0.85rem; margin-bottom: 8px; }
.book-info .genre-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-light);
}
.book-summary { color: var(--text-light); font-size: 0.85rem; margin-top: 10px; line-height: 1.5; }

/* Subscription section */
.plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin: 32px 0;
}
.plan-card { text-align: center; padding: 40px 28px; position: relative; }
.plan-card.featured { border: 2px solid var(--primary); }
.plan-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.plan-card h3 { margin-bottom: 8px; }
.plan-price { font-size: 2.2rem; font-weight: 700; color: var(--primary); font-family: 'Playfair Display', serif; }
.plan-price span { font-size: 0.9rem; color: var(--text-light); font-family: 'Inter', sans-serif; }
.plan-features { list-style: none; margin: 20px 0; }
.plan-features li { padding: 6px 0; color: var(--text-light); font-size: 0.9rem; }

/* Preferences page */
.pref-section { margin-bottom: 32px; }
.pref-section h3 { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Quantity selector */
.qty-selector {
    display: flex;
    align-items: center;
    gap: 16px;
}
.qty-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-value { font-size: 1.6rem; font-weight: 600; min-width: 40px; text-align: center; }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 24px 0 60px; min-height: 70vh; }
.admin-sidebar .card { padding: 0; }
.admin-sidebar nav a {
    display: block;
    padding: 14px 20px;
    color: var(--text-light);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    transition: all 0.15s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { background: var(--bg); color: var(--primary); font-weight: 500; }
.admin-sidebar nav a:last-child { border-bottom: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { font-weight: 600; color: var(--text-light); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: var(--bg); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-active { background: #e8f5e9; color: var(--success); }
.badge-canceled { background: #fce4e4; color: var(--error); }
.badge-pending { background: #fff3e0; color: #e67e22; }
.badge-shipped { background: #e3f2fd; color: #2196f3; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius); padding: 32px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal h2 { margin-bottom: 20px; }

/* Price display */
.price-display {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin: 24px 0;
}
.price-display .amount { font-size: 2rem; font-weight: 700; color: var(--primary); font-family: 'Playfair Display', serif; }
.price-display .detail { color: var(--text-light); font-size: 0.9rem; margin-top: 4px; }

/* Bar Chart */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 200px;
    padding: 0 4px;
    overflow-x: auto;
}
.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 28px;
    height: 100%;
    justify-content: flex-end;
}
.bar {
    width: 100%;
    max-width: 40px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 3px;
    transition: height 0.3s;
}
.bar-col:hover .bar { background: var(--accent); }
.bar-val {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-bottom: 4px;
}
.bar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50px;
}

/* Analytics two-col responsive */
@media (max-width: 900px) {
    .admin-layout + div > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); flex-direction: column; padding: 20px; border-bottom: 1px solid var(--border); gap: 12px; }
    .nav-links.open { display: flex; }
    .nav-toggle { display: flex; }
    .hero h1 { font-size: 2rem; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { order: -1; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
