/* ============================================================
   Daily Intercessions — app.css
   ============================================================ */

/* ------------------------------------------------------------
   CSS Variables
   ------------------------------------------------------------ */
:root {
    --brand:          #322361;
    --brand-dark:     #1E1545;
    --brand-light:    #EEEDFE;
    --brand-mid:      #9B93CC;

    --gold:           #E3BA3B;
    --gold-dark:      #7E631C;
    --gold-light:     #F5E6C8;

    --teal:           #1D9E75;
    --teal-light:     #E1F5EE;
    --teal-border:    #9FE1CB;

    --amber:          #BA7517;
    --amber-light:    #FAEEDA;

    --text-primary:   #2C2C2A;
    --text-secondary: #5F5E5A;
    --text-muted:     #888780;
    --text-hint:      #B4B2A9;

    --bg-page:        #FAF8F3;
    --bg-card:        #ffffff;
    --bg-surface:     #F1EFE8;

    --border:         #D3D1C7;
    --border-light:   #E8E6E0;

    --radius-sm:      4px;
    --radius-md:      8px;
    --radius-lg:      12px;

    --font-serif:     Georgia, 'Times New Roman', serif;
    --font-sans:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ------------------------------------------------------------
   Base
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    width: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-serif);
    line-height: 1.7;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    animation: pageFadeIn 0.25s ease forwards;
}

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

a {
    color: var(--brand);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------
   Auth layout
   ------------------------------------------------------------ */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 1.75rem;
    width: 100%;
}

.auth-brand img[style*="max-width"] {
    margin-bottom: 0;
}

.auth-brand-text {
    display: flex;
    flex-direction: column;
}

.auth-brand-name {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.auth-brand-tagline {
    font-size: 11px;
    font-family: var(--font-sans);
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-card {
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}

.auth-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 1.5rem;
}

.auth-help {
    font-size: 14px;
    color: var(--text-muted);
    margin: 1.25rem 0 0;
    text-align: center;
}

/* ------------------------------------------------------------
   Form elements
   ------------------------------------------------------------ */
.field {
    margin-bottom: 1rem;
}

.field label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    margin-bottom: 5px;
    letter-spacing: 0.02em;
}

.field-hint {
    font-size: 12px;
    color: var(--text-hint);
}

.field-link {
    font-size: 12px;
    color: var(--brand);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field select,
.field textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    max-width: 100%;
    width: 100%;
    padding: 9px 12px;
    font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
    font-family: var(--font-serif);
    color: var(--text-primary);
    background: var(--bg-page);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(60, 52, 137, 0.08);
}

.field textarea {
    resize: vertical;
    line-height: 1.6;
}

.field select {
    font-family: var(--font-sans);
    font-size: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888780' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn-primary {
    display: block;
    width: 100%;
    padding: 11px 20px;
    font-size: 15px;
    font-family: var(--font-serif);
    font-weight: 500;
    color: var(--brand-light);
    background: var(--brand);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    margin-top: 0.5rem;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--brand-dark);
    text-decoration: none;
    color: var(--brand-light);
}

.btn-secondary {
    display: inline-block;
    padding: 8px 18px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    background: none;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: var(--bg-surface);
    text-decoration: none;
}

/* ------------------------------------------------------------
   Alerts
   ------------------------------------------------------------ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: var(--font-sans);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.alert-success {
    background: var(--teal-light);
    border: 0.5px solid var(--teal-border);
    color: #085041;
}

.alert-error {
    background: #FCEBEB;
    border: 0.5px solid #F7C1C1;
    color: #791F1F;
}

.alert-info {
    background: var(--brand-light);
    border: 0.5px solid var(--brand-mid);
    color: var(--brand-dark);
}

.alert-warning {
    background: var(--amber-light);
    border: 0.5px solid #FAC775;
    color: #633806;
}

/* Dark mode alert overrides */
[data-theme="dark"] .alert-success {
    background: #04342C;
    border-color: #0F6E56;
    color: #9FE1CB;
}

[data-theme="dark"] .alert-error {
    background: #3A1010;
    border-color: #7A2020;
    color: #F7C1C1;
}

[data-theme="dark"] .alert-info {
    background: var(--brand-light);
    border-color: var(--brand-mid);
    color: var(--brand-dark);
}

[data-theme="dark"] .alert-warning {
    background: #2A1A00;
    border-color: #7A5000;
    color: #FAC775;
}

/* ------------------------------------------------------------
   App shell (app.php)
   ------------------------------------------------------------ */
.app-shell {
    background: var(--bg-page);
}

.app-outer {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 0 8rem;
}

/* App header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 0.5px solid var(--border-light);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header-brand {
    display: flex;
    align-items: center;
}

.app-header-name {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.app-header-tagline {
    font-size: 10px;
    font-family: var(--font-sans);
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 1px;
}

.app-nav {
    display: flex;
    gap: 6px;
}

.app-nav-btn {
    background: none;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 5px 10px;
    font-size: 12px;
    font-family: var(--font-sans);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

.app-nav-btn:hover {
    background: var(--bg-surface);
    text-decoration: none;
}

.app-nav-btn.active {
    background: var(--bg-surface);
    color: var(--text-secondary);
}

/* App body */
.app-body {
    padding: 1.25rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.stat-label {
    font-size: 11px;
    font-family: var(--font-sans);
    color: var(--text-muted);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 26px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1;
}

/* Section label */
.section-label {
    font-size: 11px;
    font-family: var(--font-sans);
    color: var(--text-hint);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

/* Intention cards */
.intention-card {
    background: var(--bg-card);
    border: 0.5px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}

.intention-card:hover {
    border-color: var(--border);
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.card-drag-handle {
    cursor: grab;
    padding: 2px 4px 2px 0;
    flex-shrink: 0;
    color: var(--text-muted);
    touch-action: none;
    margin-top: 3px;
}

.card-drag-handle:active { cursor: grabbing; }

.card-drag-ghost {
    opacity: 0.4;
    background: var(--brand-light) !important;
    border: 1px dashed var(--brand-mid) !important;
}

.sortable-chosen {
    box-shadow: 0 4px 16px rgba(50,35,97,0.12);
}

.card-title {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.card-note {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-style: italic;
    margin-bottom: 10px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 0.5px solid var(--border-light);
    padding-top: 10px;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-action {
    background: none;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-sans);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s;
}

.card-action:hover { background: var(--bg-surface); }

.card-action-answered {
    color: #085041;
    border-color: var(--teal-border);
}

.card-action-answered:hover { background: var(--teal-light); }

.card-expiry {
    font-size: 11px;
    font-family: var(--font-sans);
    color: var(--text-hint);
}

.card-expiry.urgent {
    color: var(--amber);
}

/* Category badges */
.badge {
    font-size: 10px;
    font-family: var(--font-sans);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 99px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 3px;
}

.badge-person    { background: #EEEDFE; color: #3C3489; }
.badge-situation { background: #E1F5EE; color: #085041; }
.badge-community { background: #FAEEDA; color: #633806; }
.badge-departed  { background: #F1EFE8; color: #444441; }
.badge-world     { background: #E6F1FB; color: #0C447C; }
.badge-other     { background: #F1EFE8; color: #444441; }

/* Add button */
.add-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-card);
    border: 0.5px dashed var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-serif);
    font-size: 15px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 4px;
}

.add-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-style: solid;
}

/* Closure tray */
.closure-tray {
    border: 0.5px solid var(--teal-border);
    border-radius: var(--radius-lg);
    background: var(--teal-light);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.closure-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 8px;
}

.closure-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.closure-heading {
    font-size: 14px;
    font-weight: 500;
    color: #085041;
    flex: 1;
}

.closure-count {
    font-size: 12px;
    font-family: var(--font-sans);
    color: #0F6E56;
    background: var(--teal-border);
    border-radius: 99px;
    padding: 2px 10px;
}

/* Progress bar */
.progress-wrap {
    margin-top: 8px;
    height: 2px;
    background: var(--border-light);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--brand-mid);
}

.progress-bar.urgent { background: #EF9F27; }

/* ------------------------------------------------------------
   Spinner
   ------------------------------------------------------------ */
@keyframes di-spin {
    to { transform: rotate(360deg); }
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: di-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.btn-spinner-dark {
    border-color: rgba(60,52,137,0.2);
    border-top-color: var(--brand);
}

/* ------------------------------------------------------------
   Keep in Prayer theme — site-specific overrides
   ------------------------------------------------------------ */
[data-site="kip"] {
    --brand:          #E87D2B;
    --brand-dark:     #C4611A;
    --brand-light:    #FEF0E4;
    --brand-mid:      #F5C08A;

    --gold:           #E87D2B;
    --gold-dark:      #C4611A;
    --gold-light:     #FEF0E4;

    --bg-page:        #FAF8F0;
    --bg-card:        #ffffff;
    --bg-surface:     #F2EFE6;

    --border:         #DDD8CC;
    --border-light:   #EAE6DC;
}

[data-site="kip"] .app-header {
    background: #ffffff;
}

[data-site="kip"] .btn-primary {
    background: #E87D2B;
}

[data-site="kip"] .btn-primary:hover {
    background: #C4611A;
}

[data-site="kip"][data-theme="dark"] {
    --brand:          #F5A05A;
    --brand-dark:     #FAC090;
    --brand-light:    #4A2010;
    --brand-mid:      #C4611A;
    --bg-page:        #1C1A17;
    --bg-card:        #252320;
    --bg-surface:     #2E2B25;
    --border:         #3A3630;
    --border-light:   #302D28;
}

/* Sage green for badges on KIP */
[data-site="kip"] .badge-community { background: #EAF2EA; color: #2D5A2D; }
[data-site="kip"] .badge-situation { background: #EAF2EA; color: #2D5A2D; }

/* ------------------------------------------------------------
   Dark mode
   ------------------------------------------------------------ */
[data-theme="dark"] {
    --brand:          #9B93CC;
    --brand-dark:     #C8C3E8;
    --brand-light:    #1E1545;
    --brand-mid:      #534AB7;

    --gold:           #E3BA3B;
    --gold-dark:      #EAE789;
    --gold-light:     #412402;

    --teal:           #1D9E75;
    --teal-light:     #04342C;
    --teal-border:    #0F6E56;

    --amber:          #EF9F27;
    --amber-light:    #412402;

    --text-primary:   #F1EFE8;
    --text-secondary: #C8C5BC;
    --text-muted:     #888780;
    --text-hint:      #5F5E5A;

    --bg-page:        #1A1917;
    --bg-card:        #242320;
    --bg-surface:     #2C2C2A;

    --border:         #3A3835;
    --border-light:   #2E2D2A;

    --font-serif:     Georgia, 'Times New Roman', serif;
    --font-sans:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] .app-header {
    background: #1E1D1B;
    border-bottom-color: #2E2D2A;
}

[data-theme="dark"] .intention-card,
[data-theme="dark"] #add-form {
    background: var(--bg-card);
}

[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .bottom-nav {
    background: #1E1D1B;
    border-top-color: #2E2D2A;
}

[data-theme="dark"] .stat-card {
    background: #2C2C2A;
}

[data-theme="dark"] .closure-tray {
    background: #04342C;
    border-color: #0F6E56;
}

[data-theme="dark"] .dark-toggle svg {
    stroke: #AFA9EC;
}

/* Dark mode toggle button */
.dark-toggle {
    background: none;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    color: var(--text-muted);
}

.dark-toggle:hover {
    background: var(--bg-surface);
}

/* ------------------------------------------------------------
   Bottom tab bar
   ------------------------------------------------------------ */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    display: flex;
    background: var(--bg-card);
    border-top: 0.5px solid var(--border-light);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-hint);
    text-decoration: none;
    transition: color 0.15s;
    font-family: var(--font-sans);
}

.bottom-nav-btn span {
    font-size: 10px;
    letter-spacing: 0.03em;
}

.bottom-nav-btn:hover,
.bottom-nav-btn.active {
    color: var(--brand);
    text-decoration: none;
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 480px) {
    .auth-card { border: none; border-radius: 0; padding: 1.5rem 1.25rem; }
    .auth-wrap { padding: 1rem; justify-content: flex-start; }
    .auth-brand { margin-top: 1.5rem; }
}
