/* ==========================================
   THEME TOKENS & SYSTEM VARIABLES (Grok Core)
   ========================================== */
:root[data-theme="dark"] {
    --bg-main: #09090b;           /* Pure Grok Dark Carbon */
    --surface: #121214;           /* Solid card structures */
    --surface-hover: #1a1a1e;
    --border: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 242, 254, 0.3);
    
    --text-primary: #f4f4f5;
    --text-muted: #a1a1aa;
    
    --brand-glow: #00f2fe;        /* Navi Electric Cyan */
    --brand-secondary: #a855f7;   /* Cyber Purple */
    --accent-red: #f43f5e;
    --accent-green: #10b981;
}

:root[data-theme="light"] {
    --bg-main: #f4f4f5;           /* Clean Minimal Off-White */
    --surface: #ffffff;           /* Crisp sheets */
    --surface-hover: #f4f4f5;
    --border: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(79, 172, 254, 0.3);
    
    --text-primary: #09090b;
    --text-muted: #71717a;
    
    --brand-glow: #4facfe;        /* Classic sky accent */
    --brand-secondary: #7c3aed;
    --accent-red: #e11d48;
    --accent-green: #059669;
}

/* ==========================================
   GLOBAL RESET & URBAN TYPOGRAPHY
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    word-wrap: break-word;
    -webkit-font-smoothing: antialiased;
}

/* Geometric Bold Accents for Headings */
h1, h2, h3, .brand-logo, .nav-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ==========================================
   THEME SWITCH COMPONENT (Navbar Integrated)
   ========================================== */
.theme-switch-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.theme-switch-btn:hover {
    background: var(--surface-hover);
    border-color: var(--brand-glow);
}

/* ==========================================
   RESPONSIVE LAYOUT CARDS & CONTAINERS
   ========================================== */
.dashboard-container, .auth-container, .confess-public-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

/* Fixed Mismatched Spacing on Header View */
.dashboard-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Prevents squishing on small mobile screens */
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.nav-brand {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

/* ==========================================
   GROK CARD DECK PIPELINES
   ========================================== */
.share-box, .confession-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.confession-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.unread-card {
    border-color: var(--border-glow);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.03);
}

/* Fix text breaking layout */
.confession-body {
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 16px 0;
    word-break: break-word; /* Fixes text overflowing card borders */
    white-space: pre-wrap;
}

.confession-hint {
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid var(--brand-secondary);
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Input Fields Responsive Scaling */
.link-input-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

@media (max-width: 580px) {
    .link-input-group {
        flex-direction: column; /* Stacks input + button on smaller devices */
    }
    .btn-copy {
        width: 100% !important;
    }
}

.link-input-group input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    color: var(--brand-glow);
    font-family: monospace;
    font-size: 0.95rem;
    min-width: 0; /* Important fix for flex child overflow boxes */
}

/* ==========================================
   AUTH LAYOUT DESIGN (index.php Refined)
   ========================================== */
.auth-box, .confess-public-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 440px;
    margin: auto;
}

.brand-logo {
    font-size: 2.5rem;
    letter-spacing: -0.05em;
    color: var(--text-primary);
}

.form-group input, .form-group textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--brand-glow);
}

/* Interactive Utility Buttons */
.btn {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    padding: 14px 24px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-main);
}
.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-logout {
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    background: transparent;
    padding: 6px 14px;
    font-size: 0.85rem;
}
.btn-logout:hover {
    background: var(--accent-red);
    color: white;
}
/* =========================================================================
   🆕 MINIMALIST UI ACCENTS & ICON HANDLING FOR RESPONSIVE PATTERNS
   ========================================================================= */

/* Icon-Only Anchor Framework */
.icon-link, .icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-link:hover, .icon-btn:hover {
    background: var(--surface-hover);
    border-color: var(--brand-glow);
    transform: translateY(-1px);
}

/* Card Actions Alignment Block */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.confession-time {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

/* Redesigned Icon-Only Flat Delete Action */
.icon-delete-btn {
    background: rgba(244, 63, 94, 0.05);
    border: 1px solid rgba(244, 63, 94, 0.15);
    color: var(--accent-red);
    width: 38px;
    height: 38px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-delete-btn:hover {
    background: var(--accent-red);
    color: #ffffff;
    border-color: var(--accent-red);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
}

/* Responsive Overflows Mitigation */
@media (max-width: 480px) {
    .dashboard-navbar {
        padding: 16px 0;
        gap: 8px;
    }
    
    .nav-brand {
        font-size: 1.25rem; /* Scaled down layout token to completely fit smaller screen grids */
    }
    
    .nav-actions {
        gap: 8px;
    }
    
    .icon-link, .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 1.05rem;
    }
}

/* =========================================================================
   🆕 EXPANDABLE CARD RENDERS & FORM SPACERS 
   ========================================================================= */

/* Inline Read More/Less Minimal Triggers */
.read-more-toggle {
    background: transparent;
    border: none;
    color: var(--brand-glow);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-top: 8px;
    display: inline-block;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: opacity 0.2s ease;
}

.read-more-toggle:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Fix public sheet form spacing layout */
.public-form .form-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
    font-family: inherit;
}

.public-form .form-group textarea:focus {
    border-color: var(--brand-glow);
    outline: none;
}

/* =========================================================================
   👁️ DISPLAY UTILITIES & TEXT WRAPPERS (Fixes Double Text Rendering)
   ========================================================================= */

/* Force hide the full text element initially until triggered */
.hidden {
    display: none !important;
}

/* Base style for the confession copy content block */
.confession-body {
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap; /* Maintains line breaks when expanded */
}

/* Smooth spacing for the inline action trigger */
.read-more-toggle {
    background: transparent;
    border: none;
    color: var(--brand-glow);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    margin-top: 10px;
    display: inline-block;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: opacity 0.2s ease;
}

.read-more-toggle:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* =========================================================================
   🆕 WIREFRAME MODULES: FILTER GRID & METRICS SECTION
   ========================================================================= */

/* Buttons Div: Elongated 4 Buttons in 2x2 Grid */
.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.filter-btn {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 16px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 12px;
}

.filter-btn:hover {
    border-color: var(--brand-glow);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--text-primary);
    color: var(--bg-main);
    border-color: var(--text-primary);
}

/* Metrics Div: Dashboard Stats */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.metric-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.metric-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Hide utility for JS filters */
.confession-item.hidden-item {
    display: none !important;
}

/* Footer Section Upgrades */
.app-footer {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
.app-footer a {
    color: var(--brand-glow);
    text-decoration: none;
}
.app-footer a:hover {
    text-decoration: underline;
}