/* ==============================================================================
   DrSitesi - Modern Medikal Realtime Dashboard Stilleri
   ============================================================================== */

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-border: #bae6fd;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --success-text: #065f46;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-text: #92400e;
    
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-text: #991b1b;
    
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --purple-text: #5b21b6;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header & Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Realtime Connection Status Pill */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.status-pill.connected {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.status-pill.connecting {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fde047;
}

.status-pill.disconnected {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.connected .pulse-dot {
    background: #10b981;
}

.connected .pulse-dot::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: #10b981;
    opacity: 0.5;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.connecting .pulse-dot {
    background: #eab308;
    animation: pulse 1s infinite;
}

.disconnected .pulse-dot {
    background: #ef4444;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes pulse {
    50% { opacity: 0.5; }
}

/* Main Container */
.container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 2rem;
}

/* Hero / Header Bar */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.dashboard-desc {
    color: var(--text-secondary);
    font-size: 0.925rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.btn-outline {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
}

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

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.775rem;
    border-radius: var(--radius-sm);
}

/* Metric / Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

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

.stat-info .stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0.25rem 0;
    letter-spacing: -0.02em;
}

.stat-info .stat-change {
    font-size: 0.775rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}

.stat-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-blue { background: var(--primary-light); color: var(--primary); }
.icon-green { background: var(--success-light); color: var(--success-text); }
.icon-amber { background: var(--warning-light); color: var(--warning-text); }
.icon-purple { background: var(--purple-light); color: var(--purple-text); }

/* Main Content Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 1.5rem;
}

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

/* Card Styles */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Table Filters & Search */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.search-input {
    padding: 0.55rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    width: 260px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.filter-pills {
    display: flex;
    gap: 0.35rem;
}

.filter-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.filter-btn.active, .filter-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Appointments Table */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.775rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-primary);
    vertical-align: middle;
    transition: background 0.3s ease;
}

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

.data-table tbody tr:hover td {
    background-color: #f8fafc;
}

/* Realtime Flash Effect for Updated/Inserted Rows */
@keyframes flashGreen {
    0% { background-color: #bbf7d0; }
    50% { background-color: #dcfce7; }
    100% { background-color: transparent; }
}

@keyframes flashAmber {
    0% { background-color: #fef08a; }
    50% { background-color: #fef9c3; }
    100% { background-color: transparent; }
}

@keyframes flashRed {
    0% { background-color: #fecaca; }
    50% { background-color: #fee2e2; }
    100% { background-color: transparent; }
}

.row-flash-insert td {
    animation: flashGreen 2.5s ease-out forwards;
}

.row-flash-update td {
    animation: flashAmber 2.5s ease-out forwards;
}

.row-flash-delete td {
    animation: flashRed 1.5s ease-out forwards;
}

/* Patient / Doctor Profile inside table */
.patient-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.patient-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.cell-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}

.badge-confirmed {
    background: var(--success-light);
    color: var(--success-text);
}

.badge-pending {
    background: var(--warning-light);
    color: var(--warning-text);
}

.badge-completed {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-cancelled {
    background: var(--danger-light);
    color: var(--danger-text);
}

/* Live Event Stream / Sidebar */
.live-stream-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.event-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    animation: slideInDown 0.35s ease-out;
}

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

.event-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.event-content {
    flex: 1;
}

.event-title {
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.event-time {
    font-size: 0.675rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Toast Notification Center */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.25rem;
    min-width: 320px;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

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

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-xl);
    animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

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

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

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

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.15rem;
}

.form-group label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Alert Box */
.alert-box {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    color: #92400e;
}
