/* =========================
   1. RESET & BASE
========================= */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, Arial, sans-serif;
    background: #f5f1e8;
    color: #2d2d2d;
    line-height: 1.5;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
}

/* =========================
   2. LAYOUT BASICS
========================= */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.small-container {
    max-width: 480px;
    margin: 0 auto;
}

/* =========================
   3. TYPOGRAPHY
========================= */
h1, h2, h3 {
    margin-top: 0;
    color: #35281f;
}

.brand {
    font-size: 22px;
    font-weight: bold;
    text-decoration: none;
    color: #4b3b2a;
}

.brand-subtitle {
    font-size: 13px;
    color: #8a7a68;
    margin: 2px 0 0;
}

.page-title {
    margin: 0;
    font-size: 1.6rem;
}

.page-subtitle {
    margin: 4px 0 0;
    color: #6f5c49;
    font-size: 0.95rem;
}

.context-note {
    color: #6f5c49;
    font-size: 0.92rem;
    margin: 4px 0 0;
}

.error {
    color: #c0392b;
    font-weight: 600;
}

.success {
    color: #27ae60;
    font-weight: 600;
}

/* =========================
   4. PUBLIC HEADER / FOOTER
========================= */
.public-header {
    background: #fff;
    border-bottom: 1px solid #e5ddd0;
}

.public-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 16px;
    padding-bottom: 16px;
}

.public-nav a {
    margin-left: 16px;
    text-decoration: none;
    color: #4b3b2a;
}

.public-nav a:hover {
    text-decoration: underline;
}

.public-main {
    padding-bottom: 96px;
    padding-top: 24px;
    min-height: calc(100vh - 200px);
}

.public-footer {
    text-align: center;
    color: #8a7a68;
    font-size: 13px;
    padding: 16px 0 32px;
}

/* =========================
   5. CARDS
========================= */
.card {
    background: #fff;
    border: 1px solid #e5ddd0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.empty-state {
    text-align: center;
    color: #6f5c49;
    padding: 32px 20px;
}

/* =========================
   6. BUTTONS
========================= */
button,
.button-link {
    display: inline-block;
    background: #8b6b4a;
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s ease;
}

button:hover,
.button-link:hover {
    background: #6f553b;
}

button.is-loading,
.button-link.is-loading {
    opacity: 0.85;
    cursor: wait;
    pointer-events: none;
}

.btn-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

.button-link.secondary .btn-spinner,
.btn-secondary .btn-spinner {
    border-color: rgba(74, 57, 42, 0.3);
    border-top-color: #4a392a;
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

.button-link.secondary,
.btn-secondary {
    background: #f2eadf;
    color: #4a392a;
    border: 1px solid #d8c8b2;
}

.button-link.secondary:hover,
.btn-secondary:hover {
    background: #e7dccb;
}

.btn-danger {
    background: #c0392b;
}

.btn-danger:hover {
    background: #a13125;
}

.btn-success {
    background: #27ae60;
}

.btn-success:hover {
    background: #1f8e4e;
}

/* =========================
   7. BADGES
========================= */
.badge {
    display: inline-flex;
    align-items: center;
    background: #efe4d4;
    color: #5a4632;
    border: 1px solid #decdb7;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.badge-row.compact {
    justify-content: flex-end;
}

.badge-success { background: #27ae60; color: #fff; border-color: #27ae60; }
.badge-warning { background: #f39c12; color: #fff; border-color: #f39c12; }
.badge-danger  { background: #c0392b; color: #fff; border-color: #c0392b; }
.badge-info    { background: #3498db; color: #fff; border-color: #3498db; }

/* =========================
   8. BANNERS
========================= */
.banner {
    border-left: 4px solid #8b6b4a;
    background: #fbf3e6;
}

.banner-warning {
    border-left-color: #f39c12;
    background: #fdf3e0;
}

/* =========================
   9. HERO / SEARCH (PUBLIC HOME)
========================= */
.hero {
    margin-bottom: 24px;
}

.hero-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
}

.hero-grid h1 {
    font-size: 1.8rem;
    margin: 10px 0 8px;
}

.hero-grid p {
    color: #6f5c49;
    max-width: 60ch;
    margin: 0;
}

.hero-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stats-inline-card {
    background: #fff;
    border: 1px solid #e5ddd0;
    border-radius: 10px;
    padding: 10px 16px;
    text-align: center;
    min-width: 140px;
}

.stats-inline-card strong {
    display: block;
    font-size: 1.4rem;
    color: #35281f;
}

.stats-inline-card span {
    font-size: 0.8rem;
    color: #8a7a68;
}

.search-panel {
    margin-bottom: 24px;
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    align-items: end;
}

.search-grid label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #6f5c49;
    margin-bottom: 4px;
}

.search-grid input,
.search-grid select {
    width: 100%;
}

.search-actions {
    display: flex;
    gap: 10px;
    grid-column: span 2;
}

@media (max-width: 900px) {
    .search-grid {
        grid-template-columns: 1fr 1fr;
    }

    .search-actions {
        grid-column: span 2;
    }
}

@media (max-width: 600px) {
    .search-grid {
        grid-template-columns: 1fr;
    }

    .search-actions {
        grid-column: span 1;
    }
}

/* =========================
   10. SERMON CARD LIST
========================= */
.card-list {
    display: grid;
    gap: 16px;
}

.sermon-card {
    background: linear-gradient(180deg, #fffdf9 0%, #fbf7f0 100%);
    border: 1px solid #e6dccd;
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: 0 8px 24px rgba(62, 47, 28, 0.07);
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sermon-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(62, 47, 28, 0.10);
    border-color: #d7c6ae;
}

.sermon-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.sermon-title {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.3;
    font-weight: 700;
    color: #35281f;
}

.sermon-duration {
    flex-shrink: 0;
    font-size: 12px;
    background: #efe4d4;
    color: #5a4632;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.sermon-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: #6f5c49;
    font-size: 0.92rem;
}

.sermon-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-flex;
    align-items: center;
    background: #f2eadf;
    color: #4a392a;
    border: 1px solid #d8c8b2;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.sermon-description {
    margin: 0;
    color: #554638;
    line-height: 1.58;
    font-size: 0.95rem;
    max-width: 72ch;
}

.sermon-actions {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sermon-actions .button-link,
.sermon-actions button {
    min-width: 118px;
    padding: 10px 14px;
    border-radius: 999px;
    text-align: center;
}

.play-toggle-btn {
    background: #8b5e3c;
    color: #fff;
}

.play-toggle-btn:hover {
    background: #6f472b;
}

@media (max-width: 600px) {
    .sermon-header {
        flex-direction: column;
        gap: 6px;
    }
}

/* =========================
   11. SERMON DETAIL PAGE
========================= */
.actions-bar {
    margin-bottom: 16px;
}

.sermon-card article,
article.sermon-card {
    gap: 14px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: #6f5c49;
    font-size: 0.95rem;
}

.stream-url {
    font-size: 13px;
    color: #6f5c49;
    word-break: break-all;
}

.stream-url code {
    background: #f2eadf;
    padding: 2px 6px;
    border-radius: 4px;
}

audio {
    width: 100%;
}

/* =========================
   12. GLOBAL PLAYER
========================= */
.global-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fffdf9;
    border-top: 1px solid #e5ddd0;
    box-shadow: 0 -8px 24px rgba(62, 47, 28, 0.08);
    padding: 12px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    justify-content: space-between;
    align-items: center;
}

.global-player.hidden {
    display: none;
}

.global-player-meta {
    min-width: 0;
}

.global-player-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a7a68;
}

.global-player-title {
    font-weight: 700;
    color: #35281f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}

.global-player-speaker {
    font-size: 13px;
    color: #6f5c49;
}

.global-player-audio {
    flex: 1;
    min-width: 220px;
}

.global-player-audio audio {
    width: 100%;
}

@media (max-width: 600px) {
    .global-player {
        padding: 10px 14px;
        flex-direction: column;
        align-items: stretch;
    }

    .global-player-title {
        max-width: 100%;
    }

    .global-player-audio {
        min-width: 0;
    }

    .public-main {
        padding-bottom: 150px;
    }
}

/* =========================
   13. ADMIN LAYOUT
========================= */
.admin-shell-body {
    margin: 0;
    background: #f5f1e8;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #2d2d2d;
    color: #fff;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
}

.admin-sidebar-brand .brand {
    color: #fff;
}

.admin-sidebar-brand .brand-subtitle {
    color: #bbb;
}

.sidebar-logo {
    text-align: center;
    margin-bottom: 16px;
}

.sidebar-logo img {
    max-height: 56px;
    width: auto;
}

.sidebar-nav {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar-nav a {
    display: block;
    color: #ddd;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
}

.sidebar-nav a:hover {
    background: #3d3d3d;
}

.sidebar-nav a.active {
    font-weight: bold;
    color: #fff;
    background: #4a3a28;
}

.admin-main {
    flex: 1;
    min-width: 0;
}

.admin-topbar-shell {
    padding: 20px 28px;
    border-bottom: 1px solid #e5ddd0;
    background: #fff;
}

.admin-topbar {
    margin-bottom: 16px;
}

.admin-content {
    padding: 24px 28px;
    max-width: 1100px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* =========================
   14. FORMS
========================= */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-form label {
    font-size: 13px;
    font-weight: 600;
    color: #6f5c49;
    margin-bottom: -4px;
}

.two-col-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.two-col-form .full-span {
    grid-column: span 2;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

input, textarea, select {
    padding: 9px 10px;
    border: 1px solid #d8c8b2;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #2d2d2d;
    width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid #8b6b4a;
    outline-offset: 1px;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* =========================
   15. TABLES
========================= */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid #e5ddd0;
    padding: 10px 8px;
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background: #f3efe7;
    color: #4a392a;
    font-weight: 700;
}

.admin-table tbody tr:hover {
    background: #fbf7f0;
}

.table-action {
    color: #8b5e3c;
    text-decoration: none;
    font-weight: 600;
}

.table-action:hover {
    text-decoration: underline;
}

/* =========================
   16. DASHBOARD STATS
========================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stats-card {
    background: #fff;
    border: 1px solid #e5ddd0;
    border-radius: 12px;
    padding: 16px 20px;
}

.stats-card h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8a7a68;
    margin-bottom: 6px;
}

.stats-card p {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    color: #35281f;
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================
   17. ADMIN LOGIN
========================= */
.login-body {
    background: #f5f1e8;
}

.login-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-logo-wrap {
    text-align: center;
    margin-bottom: 16px;
}

.login-logo {
    max-height: 72px;
    width: auto;
}

.login-heading {
    margin-bottom: 18px;
    text-align: center;
}

.login-heading h1 {
    margin: 0 0 6px;
}

.login-heading .page-subtitle {
    margin: 0;
}

/* =========================
   18. UTILITIES
========================= */
.inline-form {
    display: inline;
}

.pagination {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.pagination a {
    text-decoration: none;
    color: #8b5e3c;
    font-weight: 600;
}

.pagination a:hover {
    text-decoration: underline;
}

/* =========================
   19. RESPONSIVE
========================= */
@media (max-width: 768px) {
    .two-col-form {
        grid-template-columns: 1fr;
    }

    .two-col-form .full-span {
        grid-column: span 1;
    }

    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        padding: 12px 16px;
    }

    .sidebar-logo {
        display: none;
    }

    .sidebar-nav {
        margin-top: 8px;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
    }

    .sidebar-nav a {
        flex-shrink: 0;
        margin-bottom: 0;
        white-space: nowrap;
    }

    .admin-content {
        padding: 16px;
    }

    .admin-topbar-shell {
        padding: 16px;
    }
}
