/* =====================================================
   منصة د. ضياء الدين - التصميم الرئيسي
   Dr. Diaa Platform - Main Stylesheet
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #2b7a78;
    --primary-dark: #1a5c5a;
    --primary-light: #3aafa9;
    --primary-rgb: 43, 122, 120;
    --accent: #17252a;
    --bg: #f4f7f9;
    --bg-sidebar: #17252a;
    --bg-card: #ffffff;
    --bg-alt: #e8f4f3;
    --text: #17252a;
    --text-light: #5a6872;
    --text-muted: #8c9ba5;
    --border: #e2e8f0;
    --shadow: 0 2px 10px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.1);
    --success: #27ae60;
    --success-bg: #e8f8ef;
    --warning: #f39c12;
    --warning-bg: #fef9e7;
    --danger: #e74c3c;
    --danger-bg: #fce4ec;
    --info: #2980b9;
    --info-bg: #e3f2fd;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    line-height: 1.7;
}

/* ===== Layout ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--accent) 0%, var(--primary-dark) 100%);
    color: white;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition);
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand img {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: white;
    padding: 4px;
    margin-bottom: 8px;
}

.sidebar-brand h2 {
    font-size: 0.95em;
    font-weight: 700;
    color: white;
    border: none;
    margin: 0;
    padding: 0;
}

.sidebar-brand small {
    font-size: 0.75em;
    color: rgba(255,255,255,0.5);
}

.sidebar-user {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1em;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-info .name {
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-info .role {
    font-size: 0.72em;
    color: var(--primary-light);
}

.sidebar-nav {
    padding: 10px 0;
}

.sidebar-nav .nav-section {
    padding: 10px 20px 5px;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    font-weight: 700;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.88em;
    font-weight: 500;
    transition: var(--transition);
    border-right: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: white;
    border-right-color: var(--primary-light);
}

.sidebar-nav a.active {
    background: rgba(58, 175, 169, 0.15);
    color: var(--primary-light);
    border-right-color: var(--primary-light);
    font-weight: 700;
}

.sidebar-nav a .nav-icon {
    font-size: 1.15em;
    width: 22px;
    text-align: center;
}

.sidebar-nav a .nav-badge {
    margin-right: auto;
    background: var(--danger);
    color: white;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 700;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Top Bar ===== */
.topbar {
    background: white;
    padding: 12px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--text);
    cursor: pointer;
    padding: 0;
    margin-left: 15px;
}

.topbar .page-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--text);
}

.topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar .topbar-actions a,
.topbar .topbar-actions button {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.85em;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
    transition: var(--transition);
}

.topbar .topbar-actions a:hover,
.topbar .topbar-actions button:hover {
    background: var(--bg);
    color: var(--primary);
}

/* ===== Page Content ===== */
.page-content {
    padding: 25px;
    flex: 1;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg);
}

.card-header h3 {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text);
}

/* ===== Stats Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

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

.stat-card.primary { border-bottom-color: var(--primary); }
.stat-card.success { border-bottom-color: var(--success); }
.stat-card.warning { border-bottom-color: var(--warning); }
.stat-card.danger { border-bottom-color: var(--danger); }
.stat-card.info { border-bottom-color: var(--info); }

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    flex-shrink: 0;
}

.stat-card.primary .stat-icon { background: var(--bg-alt); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.info .stat-icon { background: var(--info-bg); color: var(--info); }

.stat-card .stat-info .stat-number {
    font-size: 1.6em;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-info .stat-label {
    font-size: 0.82em;
    color: var(--text-muted);
}

/* ===== Tables ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

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

table thead th {
    background: var(--bg);
    padding: 12px 15px;
    font-weight: 700;
    font-size: 0.85em;
    color: var(--text-light);
    text-align: center;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

table tbody td {
    padding: 12px 15px;
    font-size: 0.88em;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    text-align: center;
}

table tbody tr {
    transition: background 0.15s;
}

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

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 700;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--bg-alt); color: var(--primary); }
.badge-secondary { background: #f3e8ff; color: #7e22ce; }
.badge-muted { background: #f0f0f0; color: #999; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 4px 12px; font-size: 0.8em; }
.btn-lg { padding: 12px 28px; font-size: 1em; }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.88em;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9em;
    color: var(--text);
    background: white;
    transition: var(--transition);
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6872' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 35px;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--success-bg); color: #1b5e20; border-right: 4px solid var(--success); }
.alert-danger { background: var(--danger-bg); color: #b71c1c; border-right: 4px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: #e65100; border-right: 4px solid var(--warning); }
.alert-info { background: var(--info-bg); color: #0d47a1; border-right: 4px solid var(--info); }

/* ===== Search & Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 180px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.4;
}

.empty-state h3 {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-light);
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary-dark) 50%, var(--primary) 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    text-align: center;
}

.login-card .logo {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    margin: 0 auto 15px;
}

.login-card h1 {
    font-size: 1.4em;
    color: var(--primary);
    margin-bottom: 5px;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: 0.88em;
    margin-bottom: 30px;
}

.login-card .form-group {
    text-align: right;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1em;
    margin-top: 10px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

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

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 15px;
    font-size: 0.78em;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
    .sidebar { right: calc(-1 * var(--sidebar-width)); transform: none; box-shadow: none; }
    .sidebar.open { right: 0; box-shadow: -4px 0 15px rgba(0,0,0,0.1); }
    .sidebar-toggle { display: block; }
    .main-content { margin-right: 0; width: 100vw; max-width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-content { padding: 10px; }
    .card { padding: 12px; }
    
    table thead th, table tbody td {
        padding: 8px 5px;
        font-size: 0.8em;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ===== Scrollbar ===== */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* ===== Quick Actions ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    border: 2px solid transparent;
}

.quick-action:hover {
    border-color: var(--primary-light);
    background: var(--bg-alt);
}

.quick-action .qa-icon {
    font-size: 1.4em;
}

.quick-action .qa-text {
    font-weight: 600;
    font-size: 0.9em;
}

/* ===== Patient Profile Sections ===== */
.profile-section {
    margin-bottom: 25px;
}

.profile-section h3 {
    font-size: 1em;
    color: var(--primary);
    padding-bottom: 8px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--bg);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.info-item {
    display: flex;
    gap: 8px;
}

.info-item .info-label {
    font-weight: 600;
    font-size: 0.85em;
    color: var(--text-light);
    white-space: nowrap;
}

.info-item .info-value {
    font-size: 0.88em;
}

/* ===== Session Timeline ===== */
.timeline {
    position: relative;
    padding-right: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: -25px;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
}

.timeline-item.completed::before { background: var(--success); }
.timeline-item.cancelled::before { background: var(--danger); }
.timeline-item.scheduled::before { background: var(--info); }
