/* ============================================================
   PorchReads — Main Stylesheet
   Warm, cozy, personal bookshelf aesthetic
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --cream:       #FAF6F0;
    --cream-dark:  #F0E9DF;
    --brown:       #2C1A0E;
    --brown-mid:   #6B4226;
    --primary:     #B85C2A;
    --primary-h:   #9A4A20;
    --primary-lt:  #F5E6DC;
    --secondary:   #7A9E7E;
    --secondary-h: #5E8663;
    --amber:       #D97706;
    --amber-lt:    #FEF3C7;
    --blue:        #2563EB;
    --blue-lt:     #EFF6FF;
    --red:         #DC2626;
    --red-lt:      #FEE2E2;
    --green:       #16A34A;
    --green-lt:    #DCFCE7;
    --purple:      #7C3AED;
    --purple-lt:   #EDE9FE;
    --gray:        #6B7280;
    --gray-lt:     #F9FAFB;
    --white:       #FFFFFF;
    --shadow-sm:   0 1px 3px rgba(44,26,14,.08);
    --shadow-md:   0 4px 12px rgba(44,26,14,.12);
    --shadow-lg:   0 8px 24px rgba(44,26,14,.16);
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;
    --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-serif:  Georgia, 'Times New Roman', serif;
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--cream);
    color: var(--brown);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Layout ───────────────────────────────────────────────── */
.container   { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.container-sm { max-width: 680px; margin: 0 auto; padding: 0 1.25rem; }
.page-wrap   { padding: 2rem 0 3rem; }

/* ── Navigation ───────────────────────────────────────────── */
.navbar {
    background: var(--brown);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-md);
}
.navbar-inner {
    display: flex; align-items: center; gap: 1rem;
    height: 58px;
    max-width: 1100px; margin: 0 auto; padding: 0 1.25rem;
}
.navbar-brand {
    font-family: var(--font-serif);
    font-size: 1.4rem; font-weight: bold;
    color: var(--cream) !important;
    text-decoration: none;
    display: flex; align-items: center; gap: .4rem;
}
.navbar-brand .icon { font-size: 1.2rem; }
.navbar-links {
    display: flex; align-items: center; gap: .25rem; margin-left: auto;
    list-style: none;
}
.navbar-links a {
    color: rgba(250,246,240,.75);
    padding: .4rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.navbar-links a:hover,
.navbar-links a.active { background: rgba(255,255,255,.12); color: var(--cream); }
.navbar-links .btn-nav {
    background: var(--primary);
    color: var(--cream) !important;
    padding: .4rem .9rem;
    border-radius: var(--radius-sm);
}
.navbar-links .btn-nav:hover { background: var(--primary-h); }
.navbar-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 600;
    flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 500;
    cursor: pointer; border: none;
    transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none; line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-h); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-h); color: #fff; }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-lt); }
.btn-ghost     { background: transparent; color: var(--brown-mid); }
.btn-ghost:hover { background: var(--cream-dark); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-sm  { padding: .3rem .75rem; font-size: .82rem; }
.btn-lg  { padding: .7rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--cream-dark);
    overflow: hidden;
}
.card-body  { padding: 1.25rem; }
.card-header {
    padding: .9rem 1.25rem;
    background: var(--cream);
    border-bottom: 1px solid var(--cream-dark);
    font-weight: 600; font-size: .95rem;
    display: flex; align-items: center; justify-content: space-between;
}
.card-footer {
    padding: .75rem 1.25rem;
    background: var(--cream);
    border-top: 1px solid var(--cream-dark);
    font-size: .85rem; color: var(--gray);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1.1rem; }
.form-label  { display: block; font-weight: 500; margin-bottom: .35rem; font-size: .9rem; }
.form-control {
    display: block; width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid var(--cream-dark);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--brown);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(184,92,42,.12);
}
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint   { font-size: .8rem; color: var(--gray); margin-top: .3rem; }
.form-error  { font-size: .82rem; color: var(--red); margin-top: .3rem; }
.form-row    { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: var(--green-lt);  border-color: var(--green);  color: #15803d; }
.alert-error   { background: var(--red-lt);    border-color: var(--red);    color: #b91c1c; }
.alert-info    { background: var(--blue-lt);   border-color: var(--blue);   color: #1d4ed8; }
.alert-warning { background: var(--amber-lt);  border-color: var(--amber);  color: #b45309; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: .2rem;
    padding: .15rem .55rem;
    border-radius: 20px;
    font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em;
}
.badge-green  { background: var(--green-lt);  color: #15803d; }
.badge-amber  { background: var(--amber-lt);  color: #b45309; }
.badge-blue   { background: var(--blue-lt);   color: #1d4ed8; }
.badge-purple { background: var(--purple-lt); color: #6d28d9; }
.badge-red    { background: var(--red-lt);    color: #b91c1c; }
.badge-gray   { background: var(--gray-lt);   color: var(--gray); }
.badge-brown  { background: var(--primary-lt);color: var(--primary); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap  { overflow-x: auto; }
table        { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th     { background: var(--cream); padding: .65rem .85rem; text-align: left; font-weight: 600; font-size: .83rem; text-transform: uppercase; letter-spacing: .04em; color: var(--brown-mid); border-bottom: 2px solid var(--cream-dark); white-space: nowrap; }
tbody td     { padding: .7rem .85rem; border-bottom: 1px solid var(--cream-dark); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--cream); }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 1rem; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--cream-dark);
    padding: 1.1rem 1.25rem;
    text-align: center;
}
.stat-card .num  { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1.1; font-family: var(--font-serif); }
.stat-card .lbl  { font-size: .8rem; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; margin-top: .2rem; }

/* ── Book Covers ──────────────────────────────────────────── */
.book-cover {
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}
.cover-sm { width: 50px; height: 75px; }
.cover-md { width: 80px; height: 120px; }
.cover-lg { width: 120px; height: 180px; }
.cover-placeholder {
    background: var(--primary-lt);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif);
    font-size: .8rem; font-weight: 700;
    border: 1.5px dashed var(--primary);
}

/* ── Book List / Grid ─────────────────────────────────────── */
.book-list   { display: flex; flex-direction: column; gap: .75rem; }
.book-item {
    display: flex; align-items: flex-start; gap: 1rem;
    padding: .9rem;
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--cream-dark);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, border-color .15s;
}
.book-item:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }
.book-info   { flex: 1; min-width: 0; }
.book-title  { font-weight: 600; font-size: .95rem; color: var(--brown); line-height: 1.3; }
.book-author { font-size: .85rem; color: var(--brown-mid); margin-top: .15rem; }
.book-meta   { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .4rem; }
.book-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }

/* ── Stars ────────────────────────────────────────────────── */
.star      { font-size: 1rem; }
.star.full { color: var(--amber); }
.star.half { color: var(--amber); opacity: .6; }
.star.empty { color: var(--cream-dark); }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-wrap { background: var(--cream-dark); border-radius: 99px; height: 10px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 99px; background: var(--primary); transition: width .4s; }

/* ── Shelf Tabs ───────────────────────────────────────────── */
.shelf-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.25rem; }
.shelf-tab {
    padding: .4rem .9rem;
    border-radius: 99px;
    font-size: .85rem; font-weight: 500;
    cursor: pointer; border: 1.5px solid var(--cream-dark);
    background: var(--white); color: var(--brown-mid);
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}
.shelf-tab:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.shelf-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.shelf-tab .cnt {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px;
    background: rgba(0,0,0,.12);
    border-radius: 99px;
    font-size: .7rem; padding: 0 .3rem;
    margin-left: .25rem;
}

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--cream);
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.auth-header {
    background: var(--brown);
    padding: 2rem;
    text-align: center;
    color: var(--cream);
}
.auth-header h1 { font-family: var(--font-serif); font-size: 1.9rem; }
.auth-header p  { opacity: .75; font-size: .9rem; margin-top: .3rem; }
.auth-body      { padding: 1.75rem 2rem 2rem; }

/* ── Hero / Landing ───────────────────────────────────────── */
.hero {
    background: var(--brown);
    color: var(--cream);
    padding: 4rem 1.25rem;
    text-align: center;
}
.hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.2;
    margin-bottom: .75rem;
}
.hero p { font-size: 1.1rem; opacity: .8; margin-bottom: 2rem; max-width: 540px; margin-left: auto; margin-right: auto; }
.hero-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1.5rem; margin: 3rem auto; max-width: 1100px; }
.feature-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--cream-dark);
}
.feature-card .icon { font-size: 2rem; margin-bottom: .75rem; }
.feature-card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.feature-card p  { font-size: .88rem; color: var(--gray); }

/* ── Admin Sidebar ────────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - 58px); }
.admin-sidebar {
    width: 230px; flex-shrink: 0;
    background: var(--brown);
    padding: 1.5rem 0;
    position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto;
}
.admin-sidebar .sidebar-heading {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
    color: rgba(250,246,240,.45); padding: .5rem 1.25rem .25rem;
    margin-top: .5rem;
}
.admin-sidebar a {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem 1.25rem;
    color: rgba(250,246,240,.75);
    font-size: .9rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.admin-sidebar a:hover,
.admin-sidebar a.active { background: rgba(255,255,255,.1); color: var(--cream); text-decoration: none; }
.admin-sidebar a.active { border-left: 3px solid var(--primary); }
.admin-content { flex: 1; padding: 1.75rem; overflow-x: hidden; }
.admin-title   { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.25rem; display: flex; align-items: center; gap: .5rem; }

/* ── Dashboard ────────────────────────────────────────────── */
.porch-header {
    background: var(--brown);
    color: var(--cream);
    padding: 1.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex; align-items: center; gap: 1.25rem;
    box-shadow: var(--shadow-md);
}
.porch-header .avatar-lg {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700; color: #fff;
    flex-shrink: 0; overflow: hidden;
}
.porch-header h2 { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: .2rem; }
.porch-header p  { font-size: .88rem; opacity: .75; }
.section-title   { font-size: 1.05rem; font-weight: 600; margin-bottom: .9rem; color: var(--brown); display: flex; align-items: center; gap: .4rem; }

/* ── Search ───────────────────────────────────────────────── */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.search-bar input { flex: 1; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1.25rem; }
.page-btn {
    min-width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    background: var(--white); color: var(--brown-mid);
    border: 1px solid var(--cream-dark);
    text-decoration: none;
    transition: background .15s;
}
.page-btn:hover { background: var(--cream-dark); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: rgba(44,26,14,.5); align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--cream-dark);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray); padding: .2rem; }
.modal-body   { padding: 1.25rem 1.5rem; }
.modal-footer { padding: .9rem 1.5rem; border-top: 1px solid var(--cream-dark); display: flex; justify-content: flex-end; gap: .5rem; }

/* ── Misc ─────────────────────────────────────────────────── */
.text-muted   { color: var(--gray); }
.text-sm      { font-size: .85rem; }
.text-center  { text-align: center; }
.flex         { display: flex; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-sm       { gap: .5rem; }
.gap-md       { gap: 1rem; }
.mt-sm { margin-top: .5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
hr { border: none; border-top: 1px solid var(--cream-dark); margin: 1.25rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray); }
.empty-state .icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .95rem; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .form-row      { flex-direction: column; }
    .porch-header  { flex-direction: column; text-align: center; }
    .book-item     { flex-wrap: wrap; }
    .navbar-links .hide-mobile { display: none; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
    .navbar, .admin-sidebar, .btn { display: none; }
}
