/* ============================================
   PROFESSIONAL STYLES - User Management App
   ============================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--gray-800);
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================
   HEADER & TITLE
   ============================================ */

h1 {
    color: var(--gray-900);
    text-align: center;
    margin-bottom: 32px;
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h1 span {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    margin-top: 8px;
    color: var(--gray-500);
}

h1 span strong {
    color: var(--primary);
    font-weight: 600;
}

/* ============================================
   TOP BAR & STATS
   ============================================ */

.top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.date-selector {
    background: white;
    padding: 10px 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.date-selector label {
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    font-size: 0.9rem;
}

.date-selector input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.date-selector input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-today {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-today:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.stats-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-item {
    background: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 100px;
    border: 1px solid var(--gray-200);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* ============================================
   TABS & NAVIGATION
   ============================================ */

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    align-items: center;
    background: white;
    padding: 8px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.tab {
    padding: 10px 18px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.tab:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-random {
    margin-left: auto;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    box-shadow: var(--shadow);
}

.btn-random:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ============================================
   CARDS & CONTAINERS
   ============================================ */

.form-card, .table-card, .tasks-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.form-card h2, .table-card h2, .tasks-card h2 {
    color: var(--gray-900);
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.main-content {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1100px) {
    .main-content { grid-template-columns: 1fr; }
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================
   FORMS & INPUTS
   ============================================ */

.form-group { margin-bottom: 16px; }

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.875rem;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.15s;
    font-family: inherit;
    background: white;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="date"] { cursor: pointer; }

.btn-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-submit:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-cancel {
    width: 100%;
    background: var(--gray-600);
    color: white;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-cancel:hover {
    background: var(--gray-700);
}

/* ============================================
   TABLES
   ============================================ */

.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: var(--gray-50);
    color: var(--gray-700);
    padding: 2px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-200);
}

td {
    padding: 2px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
}

tr:hover { background: var(--gray-50); }
tr:last-child td { border-bottom: none; }
tr.deleting { opacity: 0.5; transition: opacity 0.3s; }
tr.unavailable { background: var(--warning-light); }

/* Center availability and actions columns */
.table-responsive tbody tr td:nth-child(3),
.table-responsive tbody tr td:nth-child(4) {
    text-align: center;
    vertical-align: middle;
}

/* ============================================
   BADGES & STATUS
   ============================================ */

.availability-badge {
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.availability-badge:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.badge-available { background: var(--success-light); color: #065f46; }
.badge-unavailable { background: var(--danger-light); color: #991b1b; }

.availability-info {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.unavailable-dates {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 400;
}

.status-icon { font-size: 0.9rem; }

/* ============================================
   REGIONS
   ============================================ */

.regions-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

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

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

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

@media (max-width: 500px) {
    .regions-grid { grid-template-columns: 1fr; }
}

.region-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--gray-50);
}

.region-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.region-name {
    font-weight: 600;
    font-size: 0.8rem;
}

.region-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.region-list {
    margin: 0;
}

.region-list li {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    border-radius: 0;
    margin: 0;
    font-size: 0.85rem;
    padding: 6px 10px;
}

.region-list li:last-child {
    border-bottom: none;
}

.empty-region {
    padding: 8px;
}

/* ============================================
   BUTTONS & ACTIONS
   ============================================ */

.action-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-action {
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
    min-width: 32px;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-edit { background: var(--warning-light); color: #92400e; }
.btn-delete { background: var(--danger-light); color: #991b1b; }

.btn-docx {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-docx:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-excel {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-excel:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-remove-user {
    background: var(--danger-light);
    color: #991b1b;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-remove-user:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

/* ============================================
   TASKS LIST
   ============================================ */

.assigned-list { list-style: none; }

.assigned-list li {
    padding: 2px 4px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--gray-200);
}

.assigned-list li span { flex: 1; }
.assigned-list li:last-child { margin-bottom: 0; }

.no-users {
    text-align: center;
    color: var(--gray-500);
    padding: 48px 20px;
    font-size: 0.95rem;
}

.empty-state {
    color: var(--gray-300);
    font-size: 3rem;
    text-align: center;
    margin-bottom: 8px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    max-width: 480px;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid var(--primary);
}

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

.toast-icon { font-size: 1.25rem; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-message {
    flex: 1;
    color: var(--gray-800);
    font-size: 0.9rem;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
}

.toast-close:hover { color: var(--gray-700); }

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

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

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

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--gray-200);
}

.modal-header h3 {
    color: var(--gray-900);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
}

.modal-close:hover { color: var(--gray-700); }

/* ============================================
   AVAILABILITY LIST
   ============================================ */

.availability-list {
    margin-top: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.availability-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 6px;
    border: 1px solid var(--gray-200);
}

.availability-item:last-child { margin-bottom: 0; }
.availability-item-info { flex: 1; }
.availability-item-dates { font-size: 0.8rem; color: var(--gray-500); }
.availability-item-reason { font-weight: 500; color: var(--gray-800); }

.availability-item-delete {
    background: var(--danger-light);
    color: #991b1b;
    border: none;
    padding: 4px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.availability-item-delete:hover {
    background: var(--danger);
    color: white;
}

.slot-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.slot-picker-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateX(4px);
}

.slot-picker-item span:first-child {
    font-weight: 500;
    color: var(--gray-800);
}

/* ============================================
   SETTINGS & INSTRUCTIONS
   ============================================ */

code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85em;
    color: var(--primary);
}

/* Stats Grid Responsive */
#stats .table-card > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
    #stats .table-card > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr;
    }
}

.edit-notice {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: #92400e;
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.edit-notice strong { font-weight: 600; }
.edit-notice a { color: inherit; text-decoration: none; font-size: 1.1rem; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    body { padding: 20px 16px; }
    h1 { font-size: 1.75rem; }
    .top-bar { flex-direction: column; }
    .tabs { flex-direction: column; align-items: stretch; }
    .btn-random { margin-left: 0; margin-top: 8px; justify-content: center; }
    .toast { min-width: auto; max-width: none; }
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-body {
    font-family: 'Roboto', sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-container {
    text-align: center;
    position: relative;
}

.login-logo {
    width: 280px;
    height: auto;
    cursor: pointer;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
    transition: transform 0.3s ease;
    opacity: 0.85;
}

.login-logo:hover {
    transform: scale(1.05);
    opacity: 1;
}

.login-form {
    margin-top: 30px;
    background: white;
    border: 1px solid var(--gray-200);
    padding: 30px;
    border-radius: 16px;
    width: 320px;
    display: none;
    animation: fadeIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.login-form.active { display: block; }

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

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 1rem;
    background: var(--gray-50);
    color: var(--gray-800);
    transition: all 0.2s;
}

.login-form input::placeholder { color: var(--gray-400); }

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-form button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.login-form button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.login-message {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 10px;
    min-height: 20px;
}

.login-hint {
    color: var(--gray-400);
    font-size: 0.8rem;
    margin-top: 20px;
}
