/** 
 * KiloChallenge Global Styles
 * Dark, modern, premium aesthetic
 */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --danger: #ef4444;
    --success: #10b981;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #818cf8;
}

/* Authentication Page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 480px;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-header p {
    color: var(--text-muted);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .half {
    flex: 1;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Date Picker Icon Styling for Dark Theme */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(0.8);
    cursor: pointer;
    transition: 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    filter: invert(1) brightness(1);
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: var(--font);
    font-size: 1rem;
}

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

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

.btn-block {
    width: 100%;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.section-title {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Details */
details.advanced-measurements {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-dark);
    border-radius: 6px;
    border: 1px solid var(--border);
}

details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
}

details div.form-row {
    margin-top: 1rem;
}

/* Sidebar Header for Mobile */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.sidebar-header h2 { margin-bottom: 0 !important; }
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container { flex-direction: column !important; }
    .sidebar { width: 100% !important; padding: 1rem !important; border-right: none !important; border-bottom: 1px solid var(--border); }
    .sidebar-header { margin-bottom: 0; }
    .mobile-menu-btn { display: block; }
    
    .nav-links { display: none; flex-direction: column; width: 100%; margin-top: 1rem; border-top: 1px solid rgba(255,255,255,0.05); padding-top: 1rem; }
    .nav-links.active { display: flex; }
    
    .nav-links li { margin: 0 0 0.5rem 0 !important; }
    .nav-links a { padding: 0.75rem 1rem !important; font-size: 1rem !important; }
    
    .main-content { padding: 1.5rem 1rem !important; }
    .top-bar { flex-direction: column; align-items: flex-start !important; gap: 1rem; }
    
    /* Force Grids and Flex Rows to Stack */
    [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .form-row { flex-direction: column; gap: 1rem; }
    .auth-card { padding: 1.5rem !important; }
    
    /* Specific overrides for chat and dashboard */
    .chat-container { flex-direction: column; height: auto !important; min-height: 80vh; }
    .chat-sidebar { width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border); height: 250px; }
    div[style*="gap: 2rem"] { gap: 1rem !important; flex-direction: column !important; }
    div[style*="flex: 2"] { min-width: 100% !important; flex: 1 !important; }
    div[style*="flex: 1"] { min-width: 100% !important; }
}
