/* Family Website Styles - Mobile First */

/* ===== iOS SAFARI / CHROME MOBILE FIXES ===== */

/* Prevent iOS from zooming on input focus */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Use safe viewport height for iOS */
html {
    height: -webkit-fill-available;
}

/* Prevent text size adjustment */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Fix tap highlight on iOS */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Prevent iOS rubber-banding in wrong places */
body {
    overscroll-behavior-y: none;
}

/* ===== END iOS FIXES ===== */

:root {
    --primary: #4a6fa5;
    --primary-dark: #3a5a8a;
    --secondary: #6b8f71;
    --accent: #d4a574;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --border: #dfe6e9;
    --shadow: rgba(0, 0, 0, 0.1);
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --family-color: #4a6fa5;
    --friends-color: #6b8f71;
    --kids-color: #e056fd;
    
    --sidebar-width: 260px;
    --header-height: 60px;
    --chat-width: 350px;
}

/* Dark Mode Theme */
[data-theme="dark"] {
    --primary: #6da3e0;
    --primary-dark: #5a8fd0;
    --secondary: #8fbf95;
    --accent: #e8c090;
    --background: #121212;
    --surface: #1e1e1e;
    --text: #ffffff;
    --text-light: #b0b0b0;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.4);
}

/* Kids Themes - Clean color only, no theme-specific icons */
[data-theme="turtle"] {
    --primary: #2e8b57;
    --primary-dark: #228b22;
    --secondary: #8fbc8f;
    --accent: #98fb98;
    --background: #e8f5e9;
    --surface: #ffffff;
    --text: #1b5e20;
    --text-light: #388e3c;
    --border: #a5d6a7;
    --kids-color: #2e8b57;
}

[data-theme="turtle-dark"] {
    --primary: #4caf50;
    --primary-dark: #388e3c;
    --secondary: #81c784;
    --accent: #b9f6ca;
    --background: #1a1a1a;
    --surface: #212121;
    --text: #ffffff;
    --text-light: #b0b0b0;
    --border: #2e7d32;
    --kids-color: #4caf50;
}

[data-theme="unicorn"] {
    --primary: #e91e63;
    --primary-dark: #c2185b;
    --secondary: #f48fb1;
    --accent: #ffd54f;
    --background: #fce4ec;
    --surface: #ffffff;
    --text: #880e4f;
    --text-light: #ad1457;
    --border: #f8bbd9;
    --kids-color: #e91e63;
}

[data-theme="unicorn-dark"] {
    --primary: #f06292;
    --primary-dark: #ec407a;
    --secondary: #ba68c8;
    --accent: #ffd54f;
    --background: #1a1a1a;
    --surface: #212121;
    --text: #ffffff;
    --text-light: #b0b0b0;
    --border: #7b1fa2;
    --kids-color: #f06292;
}

[data-theme="ocean"] {
    --primary: #00bcd4;
    --primary-dark: #0097a7;
    --secondary: #4dd0e1;
    --accent: #ffeb3b;
    --background: #e0f7fa;
    --surface: #ffffff;
    --text: #006064;
    --text-light: #00838f;
    --border: #80deea;
    --kids-color: #00bcd4;
}

[data-theme="ocean-dark"] {
    --primary: #26c6da;
    --primary-dark: #00acc1;
    --secondary: #4dd0e1;
    --accent: #ffeb3b;
    --background: #1a1a1a;
    --surface: #212121;
    --text: #ffffff;
    --text-light: #b0b0b0;
    --border: #00838f;
    --kids-color: #26c6da;
}

[data-theme="space"] {
    --primary: #9c27b0;
    --primary-dark: #7b1fa2;
    --secondary: #ce93d8;
    --accent: #ffeb3b;
    --background: #0a0a1a;
    --surface: #1a1a2e;
    --text: #ffffff;
    --text-light: #b0b0b0;
    --border: #2a2a4a;
    --kids-color: #9c27b0;
}

[data-theme="sunset"] {
    --primary: #ff7043;
    --primary-dark: #f4511e;
    --secondary: #ffab91;
    --accent: #ffd54f;
    --background: #fff3e0;
    --surface: #ffffff;
    --text: #bf360c;
    --text-light: #e65100;
    --border: #ffccbc;
    --kids-color: #ff7043;
}

[data-theme="sunset-dark"] {
    --primary: #ff8a65;
    --primary-dark: #ff7043;
    --secondary: #ffab91;
    --accent: #ffd54f;
    --background: #1a1a1a;
    --surface: #212121;
    --text: #ffffff;
    --text-light: #b0b0b0;
    --border: #e64a19;
    --kids-color: #ff8a65;
}

/* Background fix for gradient themes */
[data-theme="unicorn"] body,
[data-theme="unicorn-dark"] body {
    background: var(--background);
    background-attachment: fixed;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 16px;
}

/* ==================== LOGIN PAGE ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box-unified {
    background: var(--surface);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .login-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

.section-selector {
    margin-top: 25px;
    text-align: center;
}

.section-selector p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.section-buttons {
    display: flex;
    gap: 15px;
}

.section-option {
    flex: 1;
    cursor: pointer;
}

.section-option input {
    display: none;
}

.section-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.section-btn .section-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.section-btn .section-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.section-option input:checked + .section-btn.family {
    border-color: var(--family-color);
    background: rgba(74, 111, 165, 0.1);
}

.section-option input:checked + .section-btn.friends {
    border-color: var(--friends-color);
    background: rgba(107, 143, 113, 0.1);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-logout {
    background: var(--danger);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
}

/* ==================== SECTION SWITCHER ==================== */
.section-switcher {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 10px 12px;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}
.section-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-light);
    background: var(--surface);
    border: 2px solid transparent;
    transition: all 0.2s;
    font-size: 0.75rem;
}
.section-btn:hover {
    border-color: var(--border);
    color: var(--text);
}
.section-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.section-icon {
    font-size: 1rem;
}
.section-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
@media (max-width: 768px) {
    .section-switcher {
        padding: 8px 10px;
        gap: 5px;
    }
    .section-btn {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    .section-icon {
        font-size: 0.9rem;
    }
}

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    color: var(--primary);
}

.sidebar-header .user-info {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.sidebar-nav {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    padding: 0 20px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: var(--background);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-link i {
    width: 24px;
    margin-right: 10px;
    font-style: normal;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.nav-link.active .nav-badge {
    background: rgba(255,255,255,0.3);
}

/* Sidebar Footer with Logout */
.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .btn-logout {
    width: 100%;
    display: block;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-header {
    background: var(--surface);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h2 {
    font-size: 1.25rem;
    color: var(--text);
}

.page-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    padding-bottom: 100px; /* Space for chat */
}

/* Mobile Menu Button - Now always visible */
.mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    color: var(--text);
}

.mobile-menu-btn:hover {
    color: var(--primary);
}

/* Mobile Logout Button - Always Visible */
.mobile-logout {
    display: block;
}

/* Sidebar Footer logout - hide on mobile since we have header logout */
@media (max-width: 768px) {
    .sidebar-footer {
        display: none;
    }
}

/* ==================== SIDEBAR COLLAPSE STATE ==================== */
.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* Hide sidebar overlay on desktop by default */
.sidebar-overlay {
    display: none;
}

/* ==================== MOBILE STYLES ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Reset collapsed state on mobile - use open instead */
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }
    
    .sidebar-overlay.open {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .mobile-logout {
        display: block;
        margin-left: auto;
    }
    
    .page-header {
        padding: 12px 15px;
    }
    
    .page-header h2 {
        font-size: 1.1rem;
        flex: 1;
        text-align: center;
    }
    
    .page-body {
        padding: 15px;
    }
    
    /* Chat adjustments for mobile */
    .chat-container {
        width: 100%;
        right: 0;
        left: 0;
        bottom: 0;
        border-radius: 0;
    }
    
    .chat-box {
        border-radius: 15px 15px 0 0;
        max-height: 60vh;
    }
    
    /* Grid adjustments */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    
    .card-header, .card-body {
        padding: 15px;
    }
    
    /* Tables */
    .data-table {
        display: block;
        overflow-x: auto;
    }
    
    /* Forms */
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ==================== EXTRA SMALL MOBILE (under 480px) ==================== */
@media (max-width: 480px) {
    .page-body {
        padding: 10px;
    }
    
    .card-header, .card-body {
        padding: 12px;
    }
    
    /* Life subnav scrollable on small screens */
    .life-subnav {
        padding: 8px;
        gap: 6px;
    }
    
    .subnav-item {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    /* Stopwatch grids */
    .stopwatch-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    
    .stopwatch-card {
        padding: 12px 8px;
    }
    
    .stopwatch-icon {
        font-size: 1.5rem;
    }
    
    .stopwatch-time {
        font-size: 1.2rem;
    }
    
    .stopwatch-btn {
        padding: 8px;
        font-size: 0.75rem;
    }
    
    /* Today stats */
    .today-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    /* Timer grids */
    .timer-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px;
    }
    
    .timer-card {
        padding: 12px 8px;
    }
    
    /* Quick edit grids */
    .quick-edit-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Mode toggle */
    .mode-toggle {
        gap: 6px;
    }
    
    .mode-btn {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
    
    /* Quick actions */
    .quick-actions {
        flex-wrap: wrap;
    }
    
    .quick-btn {
        flex: 1;
        min-width: 100px;
        justify-content: center;
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    /* Care sections */
    .section-header {
        padding: 10px 12px;
    }
    
    .care-items {
        padding: 8px;
    }
    
    .care-item {
        padding: 10px;
        gap: 10px;
    }
    
    .care-checkbox {
        width: 22px;
        height: 22px;
    }
    
    .care-name {
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    /* Header adjustments */
    .page-header h2 {
        font-size: 1rem;
    }
    
    /* Section switcher */
    .section-btn {
        padding: 5px 6px;
    }
    
    .section-label {
        display: none;
    }
    
    .section-icon {
        font-size: 1.1rem;
    }
}

/* ==================== IFRAME CONTAINER FIXES ==================== */
/* Fix iframe sizing for Safari vs Chrome */
.life-module-container iframe {
    width: 100%;
    min-height: 600px;
    max-width: 100%;
    border: none;
    border-radius: 10px;
    background: var(--surface);
    display: block;
}

/* Safari-specific iframe fix */
@supports (-webkit-touch-callout: none) {
    .life-module-container iframe {
        min-height: calc(100vh - 200px);
        height: auto;
    }
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

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

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 1.05rem;
}

.card-body {
    padding: 20px;
}

/* ==================== MODALS ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal h3 {
    margin-bottom: 20px;
    text-align: center;
}

/* ==================== CHAT SYSTEM - Icon Based ==================== */
.chat-icons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-icon-btn {
    width: auto;
    min-width: 50px;
    height: 50px;
    padding: 0 15px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    color: white;
}

.chat-icon-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.chat-icon-btn.family {
    background: var(--family-color);
}

.chat-icon-btn.friends {
    background: var(--friends-color);
}

.chat-icon-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.chat-icon-badge.show {
    display: flex;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.chat-window {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 340px;
    background: var(--surface);
    border-radius: 15px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    height: 400px;
    z-index: 10000;
    animation: chatSlideUp 0.3s ease;
}

.chat-window.open {
    display: flex;
}

.chat-window.family-window {
    right: 80px;
}

.chat-window.friends-window {
    right: 20px;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-radius: 15px 15px 0 0;
}

.chat-header.family {
    background: var(--family-color);
}

.chat-header.friends {
    background: var(--friends-color);
}

.chat-header h4 {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

.chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: var(--background);
}

.chat-message {
    margin-bottom: 12px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message .sender {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 3px;
}

.chat-message .text {
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 12px;
    border-top-left-radius: 4px;
    display: inline-block;
    max-width: 85%;
    word-wrap: break-word;
}

.chat-message.own {
    text-align: right;
}

.chat-message.own .sender {
    color: var(--secondary);
}

.chat-message.own .text {
    background: var(--primary);
    color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 4px;
}

.chat-message .time {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 3px;
}

.chat-message-image {
    max-width: 200px;
    border-radius: 10px;
    margin-top: 5px;
    cursor: pointer;
}

.chat-input-area {
    border-top: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0 0 15px 15px;
}

.chat-input-row {
    display: flex;
    padding: 10px;
    gap: 8px;
    align-items: center;
}

.chat-input-row input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
}

.chat-input-row input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-photo-btn {
    background: var(--background);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
}

/* Mobile chat adjustments */
@media (max-width: 768px) {
    .chat-icons {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-icon-btn {
        width: 45px;
        height: 45px;
    }
    
    .chat-window {
        width: calc(100% - 30px);
        left: 15px;
        right: 15px;
        bottom: 75px;
        height: 50vh;
    }
    
    .chat-window.family-window,
    .chat-window.friends-window {
        right: 15px;
    }
}

/* ==================== GRIDS ==================== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ==================== TABLES ==================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--background);
    font-weight: 600;
    font-size: 0.85rem;
}

.data-table tr:hover {
    background: var(--background);
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin { background: var(--danger); color: white; }
.badge-family { background: var(--family-color); color: white; }
.badge-friend { background: var(--friends-color); color: white; }
.badge-both { background: var(--accent); color: white; }

/* ==================== ALERTS ==================== */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Dark mode alerts */
[data-theme="dark"] .alert-success {
    background: #1a3a1a;
    color: #6c6;
    border-color: #2a4a2a;
}

[data-theme="dark"] .alert-error {
    background: #3a1a1a;
    color: #f88;
    border-color: #4a2a2a;
}

[data-theme="dark"] .alert-info {
    background: #1a2a3a;
    color: #6cf;
    border-color: #2a4a6a;
}

/* ==================== FLOATING BOXES ==================== */
.floating-box {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1001;
    padding: 25px;
}

.floating-box.active {
    display: block;
    animation: modalSlide 0.3s ease;
}

.floating-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.floating-box-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

/* ==================== CALENDAR ==================== */
.calendar {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
}

.calendar-header {
    background: var(--primary);
    color: white;
    padding: 15px;
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-nav {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day-header {
    padding: 10px 5px;
    text-align: center;
    font-weight: 600;
    background: var(--background);
    font-size: 0.8rem;
}

.calendar-day {
    padding: 8px;
    text-align: center;
    border: 1px solid var(--border);
    min-height: 70px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.calendar-day:hover {
    background: var(--background);
}

.calendar-day.other-month {
    color: var(--text-light);
    background: var(--background);
}

.calendar-day.today {
    background: var(--primary);
    color: white;
}

.calendar-event {
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 3px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== TIMELINE ==================== */
.timeline {
    position: relative;
    padding-left: 25px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 25px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 5px;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid var(--surface);
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 5px;
}

.timeline-content {
    background: var(--surface);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: box-shadow 0.3s;
}

.timeline-content:hover {
    box-shadow: 0 4px 15px var(--shadow);
}

/* ==================== PHOTO GRID ==================== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.photo-item {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s;
    position: relative;
}

.photo-item:hover {
    transform: scale(1.03);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
}

/* ==================== GAME CARDS ==================== */
.game-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.3s;
}

.game-card:hover {
    transform: translateY(-3px);
}

.game-card-image {
    height: 140px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.game-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-card-body {
    padding: 15px;
}

.game-card-body h4 {
    margin-bottom: 5px;
}

.rating-stars {
    color: var(--warning);
    font-size: 0.9rem;
}

.rating-stars .empty {
    color: var(--border);
}

/* ==================== HANGOUT IDEAS ==================== */
.idea-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--shadow);
    border-left: 4px solid var(--primary);
}

.idea-card.online {
    border-left-color: var(--secondary);
}

.idea-card.in-person {
    border-left-color: var(--accent);
}

.idea-meta {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.idea-tag {
    background: var(--background);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ==================== DISCORD WIDGET ==================== */
.discord-widget {
    background: #5865F2;
    border-radius: 12px;
    padding: 20px;
    color: white;
    text-align: center;
}

.discord-widget h3 {
    margin-bottom: 15px;
}

.discord-widget a {
    display: inline-block;
    background: white;
    color: #5865F2;
    padding: 12px 25px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 10px;
}

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-light { color: var(--text-light); }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.p-15 { padding: 15px; }
.p-20 { padding: 20px; }
.hidden { display: none; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.gap-20 { gap: 20px; }
.flex-wrap { flex-wrap: wrap; }

/* ==================== SERVER STATUS ==================== */
.server-status {
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
}

.server-status.online {
    border: 2px solid var(--success);
}

.server-status.offline {
    border: 2px solid var(--danger);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background: var(--success);
}

.status-indicator.offline {
    background: var(--danger);
}

/* ==================== RECIPE CARDS ==================== */
.recipe-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.3s;
}

.recipe-card:hover {
    transform: translateY(-3px);
}

.recipe-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.recipe-card-body {
    padding: 15px;
}

.recipe-card h4 {
    margin-bottom: 5px;
    font-size: 1rem;
}

.recipe-card .meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ==================== FAMILY TREE ==================== */
.tree-node {
    display: inline-block;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 15px 20px;
    margin: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.tree-node:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--shadow);
}

.tree-node img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 8px;
    object-fit: cover;
}

.tree-node h4 {
    font-size: 0.9rem;
    margin-bottom: 3px;
}

.tree-node .dates {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ==================== INTEGRATED CHAT PANEL ==================== */
.chat-toggle-btn,
.theme-toggle-btn {
    position: relative;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s;
}
.chat-toggle-btn:hover,
.theme-toggle-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
}

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

.chat-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 350px;
    height: 100vh;
    background: var(--surface);
    box-shadow: -5px 0 25px var(--shadow);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    transition: right 0.3s;
}
.chat-panel.open { right: 0; }

.chat-panel-header {
    padding: 15px 20px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-panel-header h4 { margin: 0; }
.chat-panel-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
}

.chat-panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.chat-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--background);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.chat-tab:hover { background: var(--border); }
.chat-tab.active {
    background: var(--surface);
    border-bottom: 3px solid var(--primary);
}

.chat-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.chat-msg {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--background);
    max-width: 85%;
}
.chat-msg.own {
    background: var(--primary);
    color: white;
    margin-left: auto;
}
.chat-msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.8;
}
.chat-msg-text { word-wrap: break-word; }

.chat-panel-input {
    padding: 15px;
    border-top: 1px solid var(--border);
    position: relative;
}
.chat-panel-input form {
    display: flex;
    gap: 8px;
}
.chat-panel-input input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: var(--background);
    color: var(--text);
}
.emoji-btn, .chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
}
.emoji-btn { background: var(--background); }
.chat-send { background: var(--primary); color: white; }

.emoji-picker {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 5px 20px var(--shadow);
    z-index: 10;
}
.emoji-picker.show { display: block; }
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
}
.emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.2rem;
}
.emoji-item:hover { background: var(--background); }

/* ==================== THEME BUTTON ==================== */
.btn-theme {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    margin-right: 10px;
}
.btn-theme:hover { background: var(--border); }

.sidebar-footer {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 10px;
}

/* ==================== KIDS BADGE ==================== */
.badge-kid {
    background: linear-gradient(135deg, #ff69b4, #9370db);
    color: white;
}

@media (max-width: 768px) {
    .chat-panel {
        width: 100%;
        right: -100%;
    }
    .chat-panel.open { right: 0; }
    
    .chat-toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .header-actions .mobile-logout {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* ==================== DARK MODE FIXES ==================== */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--background);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-light);
}

[data-theme="dark"] .card p,
[data-theme="dark"] .card span,
[data-theme="dark"] .card label,
[data-theme="dark"] .card td,
[data-theme="dark"] .card th {
    color: var(--text);
}

[data-theme="dark"] .btn-outline {
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .btn-outline:hover {
    background: var(--border);
}

[data-theme="dark"] table th {
    background: var(--background);
    color: var(--text);
}

[data-theme="dark"] table td {
    border-color: var(--border);
}

[data-theme="dark"] .modal {
    background: var(--surface);
}

[data-theme="dark"] .modal h3 {
    color: var(--text);
}

[data-theme="dark"] .form-group label {
    color: var(--text);
}

/* Fix any remaining hardcoded colors */
[data-theme="dark"] .text-dark {
    color: var(--text) !important;
}
