:root {
    --bg-main: #0a0813;
    --bg-card: rgba(25, 22, 43, 0.55);
    --bg-input: rgba(15, 12, 28, 0.7);
    --border-color: rgba(255, 255, 255, 0.07);
    --text-primary: #f3f1fa;
    --text-secondary: #a09cb0;
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --purple-grad: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    --blue-grad: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --green-grad: linear-gradient(135deg, #10b981 0%, #047857 100%);
    --pink-grad: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 10% 10%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    animation: pulse 3s infinite ease-in-out;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(to right, #f3f1fa, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--error-color);
    color: white;
    transform: translateY(-2px);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.stat-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.purple-gradient { background: var(--purple-grad); }
.blue-gradient { background: var(--blue-grad); }
.green-gradient { background: var(--green-grad); }
.pink-gradient { background: var(--pink-grad); }

.stat-content h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-value-text {
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 170px;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Workspaces Grid */
.main-workspace {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* Tables Section */
.table-card {
    padding: 1.75rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h2 {
    font-size: 1.35rem;
    font-weight: 600;
}

.badge {
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

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

tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

.text-right {
    text-align: right;
}

/* Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    text-transform: uppercase;
}

.status-badge::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.active {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--success-color);
}
.status-badge.active::before { background-color: var(--success-color); }

.status-badge.inactive {
    background-color: rgba(160, 156, 176, 0.12);
    color: var(--text-secondary);
}
.status-badge.inactive::before { background-color: var(--text-secondary); }

.status-badge.success {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--success-color);
}
.status-badge.success::before { background-color: var(--success-color); }

.status-badge.fail {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--error-color);
}
.status-badge.fail::before { background-color: var(--error-color); }

/* Day Codes list formatting */
.days-badges {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.day-badge {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--text-secondary);
}

.day-badge.active-day {
    background-color: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

/* Action Groups */
.action-group {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Modal Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(5, 4, 10, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease-out;
}

.overlay.hidden {
    display: none !important;
}

.modal-card {
    width: 100%;
    max-width: 600px;
    margin: 1.5rem;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

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

.flex-1 { flex: 1; }

label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

input[type="text"], input[type="password"], input[type="time"], textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Toggle Switch */
.toggle-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 42px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--success-color);
    border-color: rgba(16, 185, 129, 0.3);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-color: white;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Weekday Selector in modal */
.days-selector {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.day-btn {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.day-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.day-btn.selected {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.25);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* Login Card Override */
.login-card {
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-card button {
    width: 100%;
    margin-top: 0.75rem;
    justify-content: center;
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.loading-state {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-secondary);
}

/* Toasts Container */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
}

.toast {
    min-width: 280px;
    max-width: 400px;
    background-color: #17142b;
    border-left: 4px solid var(--primary-color);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.success { border-left-color: var(--success-color); }
.toast.error { border-left-color: var(--error-color); }
.toast.warning { border-left-color: var(--warning-color); }

.toast-content {
    font-size: 0.9rem;
    font-weight: 500;
}

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

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

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

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

/* Responsive Media Queries for Mobile Screens */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        gap: 1.25rem;
        align-items: stretch;
        text-align: center;
        margin-bottom: 2rem;
    }

    .logo-area {
        flex-direction: column;
        gap: 0.5rem;
        justify-content: center;
    }

    .logo-icon {
        font-size: 2.25rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .header-actions {
        justify-content: center;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 3rem;
        height: 3rem;
        border-radius: 12px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-value-text {
        font-size: 1rem;
        max-width: 100%;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-header h2 {
        font-size: 1.2rem;
    }

    .table-card {
        padding: 1.25rem 1rem;
    }

    /* Convert tables to responsive cards on mobile */
    .table-responsive {
        overflow-x: visible; /* No need for scrollbar now */
    }

    table, thead, tbody, th, td, tr {
        display: block;
        width: 100%;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid var(--border-color);
        border-radius: 16px;
        margin-bottom: 1.25rem;
        padding: 1rem;
        box-sizing: border-box;
        transition: var(--transition);
    }

    tr:hover {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.1);
    }

    td {
        border-bottom: 1px solid rgba(255, 255, 255, 0.02);
        padding: 0.75rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        font-size: 0.9rem;
    }

    td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-right: 1rem;
    }

    .message-preview {
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.85rem;
    }

    /* Ensure actions are grouped nicely */
    .action-group {
        gap: 0.5rem;
        width: 100%;
        justify-content: flex-end;
    }

    .btn-icon {
        padding: 0.35rem;
    }

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

    .days-selector {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.35rem;
    }

    .day-btn {
        flex: unset;
        width: 100%;
        padding: 0.5rem 0;
        font-size: 0.8rem;
    }

    .modal-card {
        margin: 1rem 0.5rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .modal-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .modal-footer {
        margin-top: 1.25rem;
        padding-top: 1rem;
    }
    
    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
    
    .toast {
        min-width: unset;
        width: 100%;
    }
}
