/* =============================================
   Clinic Management System - Main Styles
   Design System & Core Layout
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&display=swap');

/* =============================================
   CSS Custom Properties (Design Tokens)
   ============================================= */
:root {
    /* Primary Colors */
    --primary-dark: #1E3A8A;
    --primary-light: #3B82F6;
    --primary-lighter: #60A5FA;
    --primary-gradient: linear-gradient(135deg, #1E3A8A 0%, #3B82F6 100%);

    /* Backgrounds */
    --bg-white: #FFFFFF;
    --bg-light: #F3F4F6;
    --bg-card: #FFFFFF;

    /* Text Colors */
    --text-heading: #111827;
    --text-primary: #374151;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-white: #FFFFFF;

    /* Accent Colors */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    /* Buttons */
    --btn-primary: #3B82F6;
    --btn-primary-hover: #2563EB;
    --btn-secondary: #E5E7EB;
    --btn-secondary-hover: #D1D5DB;

    /* Borders */
    --border-color: #E5E7EB;
    --border-radius-sm: 6px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Font Family */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-secondary: 'Poppins', sans-serif;
}

/* =============================================
   CSS Reset & Base Styles
   ============================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-light);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul,
ol {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
}

/* =============================================
   Typography
   ============================================= */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-secondary);
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.125rem;
}

h5 {
    font-size: 1rem;
}

h6 {
    font-size: 0.875rem;
}

.text-primary {
    color: var(--primary-light);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.text-muted {
    color: var(--text-muted);
}

/* =============================================
   Layout Structure
   ============================================= */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    /* Changed from left: 0 for RTL */
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary-gradient);
    padding: 0;
    z-index: 1000;
    transition: right var(--transition), transform var(--transition), visibility var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Sidebar Logo */
.sidebar-logo {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

.sidebar-logo .logo-icon {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.sidebar-logo h2 {
    color: var(--text-white);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-logo span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    display: block;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 0 0.75rem;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    border-radius: var(--border-radius);
    margin-bottom: 4px;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    right: 0;
    /* Changed from left for RTL */
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--text-white);
    transform: scaleY(0);
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.nav-item:hover::before {
    transform: scaleY(1);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-white);
}

.nav-item.active::before {
    transform: scaleY(1);
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-item span {
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item .badge {
    margin-right: auto;
    /* Changed from margin-left for RTL */
    background: var(--danger);
    color: var(--text-white);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    /* Changed from margin-left for RTL */
    margin-left: 0;
    min-height: 100vh;
    transition: var(--transition);
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-white);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    background: var(--bg-light);
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--primary-light);
    color: var(--text-white);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--primary-light);
}

.breadcrumb .separator {
    color: var(--text-muted);
}

.breadcrumb .current {
    color: var(--text-heading);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Search Box */
.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    height: 42px;
    padding: 0 1rem 0 2.75rem;
    background: var(--bg-light);
    border: 1px solid transparent;
    border-radius: var(--border-radius-lg);
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.search-box input:focus {
    background: var(--bg-white);
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box i {
    position: absolute;
    right: 1rem;
    /* Changed from left: 1rem for RTL */
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Header Icons */
.header-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius);
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--text-secondary);
    position: relative;
    cursor: pointer;
    transition: var(--transition-fast);
}

.header-icon:hover {
    background: var(--primary-light);
    color: var(--text-white);
}

.header-icon .notification-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    /* Changed from right: 8px for RTL */
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-white);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--bg-light);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-profile:hover {
    background: var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-heading);
}

.user-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Page Content */
.page-content {
    padding: 1.5rem 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* =============================================
   Statistics Cards
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    /* Changed from left for RTL */
    width: 4px;
    height: 100%;
    background: var(--primary-light);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card.success::before {
    background: var(--success);
}

.stat-card.warning::before {
    background: var(--warning);
}

.stat-card.danger::before {
    background: var(--danger);
}

.stat-card.info::before {
    background: var(--info);
}

.stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card.info .stat-card-icon {
    background: var(--info-light);
    color: var(--info);
}

.stat-card.success .stat-card-icon {
    background: var(--success-light);
    color: var(--success);
}

.stat-card.warning .stat-card-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card.danger .stat-card-icon {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-card-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
}

.stat-card-trend.up {
    background: var(--success-light);
    color: var(--success);
}

.stat-card-trend.down {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
}

.stat-card-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* =============================================
   Cards & Containers
   ============================================= */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--primary-light);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-3-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

/* =============================================
   Charts Container
   ============================================= */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* =============================================
   Quick Actions & Lists
   ============================================= */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.action-btn.primary {
    background: var(--primary-light);
    color: var(--text-white);
}

.action-btn.primary:hover {
    background: var(--btn-primary-hover);
}

.action-btn.secondary {
    background: var(--btn-secondary);
    color: var(--text-primary);
}

.action-btn.secondary:hover {
    background: var(--btn-secondary-hover);
}

/* Recent Items List */
.recent-list {
    max-height: 350px;
    overflow-y: auto;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-item:hover {
    background: var(--bg-light);
    margin: 0 -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.recent-item-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--primary-light);
    flex-shrink: 0;
}

.recent-item-info {
    flex: 1;
    min-width: 0;
}

.recent-item-info h4 {
    font-size: 0.9375rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item-info span {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.recent-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Appointments List */
.appointment-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
    transition: var(--transition-fast);
}

.appointment-item:hover {
    box-shadow: var(--shadow);
}

.appointment-time {
    text-align: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-white);
    border-radius: var(--border-radius);
    min-width: 60px;
}

.appointment-time .time {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
}

.appointment-time .period {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.appointment-info {
    flex: 1;
}

.appointment-info h4 {
    font-size: 0.9375rem;
    margin-bottom: 2px;
}

.appointment-info span {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.appointment-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.appointment-status.booked {
    background: var(--info-light);
    color: var(--info);
}

.appointment-status.completed {
    background: var(--success-light);
    color: var(--success);
}

.appointment-status.cancelled {
    background: var(--danger-light);
    color: var(--danger);
}

/* Low Stock Alert */
.alert-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--warning-light);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--warning);
}

.alert-item i {
    color: var(--warning);
    font-size: 1.125rem;
}

.alert-item-info {
    flex: 1;
}

.alert-item-info h4 {
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.alert-item-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.alert-item-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--warning);
}

/* =============================================
   Utility Classes
   ============================================= */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.p-1 {
    padding: 0.5rem;
}

.p-2 {
    padding: 1rem;
}

.p-3 {
    padding: 1.5rem;
}

.p-4 {
    padding: 2rem;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

.hidden {
    display: none;
}

.visible {
    display: block;
}