/**
 * JDM Studio - Main Stylesheet
 * Modern dark theme with cyan accents
 */

/* =====================================================
   CSS VARIABLES & RESET
   ===================================================== */
:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #15151f;
    --bg-hover: #1f1f2e;
    
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    
    --accent-primary: #00d4ff;
    --accent-secondary: #00a8cc;
    --accent-glow: rgba(0, 212, 255, 0.3);
    
    --success: #00e676;
    --warning: #ffab00;
    --error: #ff5252;
    --info: #448aff;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    
    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-display: 'Space Grotesk', var(--font-main);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =====================================================
   TYPOGRAPHY
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
}

/* =====================================================
   LAYOUT
   ===================================================== */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-lg);
}

.page-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: var(--spacing-xl);
    margin-left: 280px;
    min-height: 100vh;
}

@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        padding: var(--spacing-md);
    }
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.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: 1024px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

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

/* Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    flex: 1;
}

.card-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

/* Stat Cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

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

.stat-change {
    font-size: 0.875rem;
    margin-top: var(--spacing-sm);
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--error); }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.75rem 1.5rem;
    font-family: var(--font-main);
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-danger:hover:not(:disabled) {
    background: #ff3333;
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.0625rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: var(--font-main);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23606070' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.form-error {
    color: var(--error);
    font-size: 0.8125rem;
    margin-top: var(--spacing-xs);
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: var(--spacing-xs);
}

/* =====================================================
   TABLES
   ===================================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
}

.table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

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

.table tbody tr:last-child td {
    border-bottom: none;
}

/* =====================================================
   BADGES & STATUS
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-primary {
    background: var(--accent-glow);
    color: var(--accent-primary);
}

.badge-success {
    background: rgba(0, 230, 118, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 171, 0, 0.15);
    color: var(--warning);
}

.badge-error {
    background: rgba(255, 82, 82, 0.15);
    color: var(--error);
}

.badge-info {
    background: rgba(68, 138, 255, 0.15);
    color: var(--info);
}

.badge-neutral {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Status Dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.away { background: var(--warning); }

/* =====================================================
   ALERTS & NOTIFICATIONS
   ===================================================== */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    margin-bottom: var(--spacing-lg);
}

.alert-success {
    background: rgba(0, 230, 118, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: rgba(255, 171, 0, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-error {
    background: rgba(255, 82, 82, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.alert-info {
    background: rgba(68, 138, 255, 0.1);
    border-color: var(--info);
    color: var(--info);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    max-height: 60vh;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* =====================================================
   AVATARS
   ===================================================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--bg-primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.8125rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.25rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.75rem; }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-lg);
    color: var(--text-muted);
}

.empty-state-title {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
}

.empty-state-text {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* =====================================================
   MOBILE RESPONSIVE STYLES
   ===================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-toggle {
        display: flex !important;
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chat-container {
        flex-direction: column;
        height: auto !important;
    }
    
    .chat-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .chat-main {
        min-height: 400px;
    }
    
    .settings-panel {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        z-index: 1001;
        width: 280px !important;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --spacing-lg: 1rem;
        --spacing-xl: 1.25rem;
        --spacing-2xl: 1.5rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .header-actions .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .card {
        padding: var(--spacing-md);
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    /* Chat Mobile */
    .chat-sidebar {
        max-height: 150px;
    }
    
    .conversation-item {
        padding: 0.75rem;
    }
    
    .chat-input-container {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .input-row, .chat-input-row {
        width: 100%;
        order: 1;
    }
    
    .chat-input-container .btn-primary {
        width: 100%;
        order: 2;
    }
    
    .picker, .emoji-picker, .gif-picker {
        width: calc(100vw - 40px) !important;
        left: 0 !important;
        max-width: 320px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .chat-gif {
        max-width: 150px !important;
    }
    
    /* Schedule Mobile */
    .schedule-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 2px;
    }
    
    .schedule-cell {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .schedule-header {
        font-size: 0.7rem;
        padding: 0.5rem 0.25rem;
    }
    
    /* Modal Mobile */
    .modal {
        width: 95%;
        max-width: none;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }
    
    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Floating action button for mobile */
    .fab {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--accent-primary);
        color: var(--bg-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-lg);
        z-index: 100;
        font-size: 1.5rem;
    }
    
    /* Bottom safe area for iOS */
    .main-content {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.25rem;
    }
    
    .page-subtitle {
        font-size: 0.8rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
    
    .nav-item-badge, .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }
    
    .hours-card .hours-value {
        font-size: 1.75rem;
    }
}
