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

/* 
    Medico-domicilio.it - Premium Design System 2.0
    Font: Poppins / Dubai
    Architecture: Component-Based
*/

/* RTL Support Base */
[dir="rtl"] {
    text-align: right;
    font-family: "Dubai-Regular", sans-serif;
}

[dir="rtl"] body {
    font-family: "Dubai-Regular", sans-serif;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] .font-bold {
    font-family: "Dubai-Bold", sans-serif;
}

[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.05);
}

[dir="rtl"] .main-area {
    margin-right: 280px;
    margin-left: 0;
}

[dir="rtl"] .ml-auto {
    margin-right: auto;
    margin-left: 0;
}

[dir="rtl"] .mr-auto {
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] table th,
[dir="rtl"] table td {
    text-align: right;
}

[dir="rtl"] .flex {
    flex-direction: row-reverse;
}

[dir="rtl"] .justify-between {
    justify-content: space-between;
}

[dir="rtl"] .items-center {
    align-items: center;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

:root {
    /* Color Palette */
    --p-50: #eff6ff;
    --p-100: #dbeafe;
    --p-200: #bfdbfe;
    --p-300: #93c5fd;
    --p-400: #60a5fa;
    --p-500: #3b82f6;
    /* Shared Primary */
    --p-600: #2563eb;
    --p-700: #1d4ed8;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Theme Variables */
    --primary: var(--p-500);
    --primary-hover: var(--p-600);
    --bg-body: var(--slate-50);
    --bg-card: #ffffff;
    --text-main: var(--slate-900);
    --text-muted: var(--slate-700);
    --border: var(--slate-200);

    /* Layout */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography Extensions */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

p {
    color: var(--text-muted);
}

/* Layout Components */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Component */
.sidebar {
    width: 280px;
    background: var(--slate-900);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
    z-index: 50;
    transition: var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    margin-bottom: 3.5rem;
    text-decoration: none;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 16px -4px rgba(59, 130, 246, 0.4);
}

/* Content Area */
.main-area {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    gap: 2rem;
}

.page-header > div:first-child {
    min-width: 0;
    flex: 1;
}

.page-header h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile Header & Visibility */
.mobile-only {
    display: none !important;
}


.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0.5rem;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--slate-700);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
}

.tab-item i {
    width: 20px;
    height: 20px;
}

.tab-item.active {
    color: var(--primary);
}


/* Responsive Overrides */
@media (max-width: 992px) {
    .mobile-only {
        display: flex !important;
    }

    .sidebar, .sidebar-backdrop {
        display: none !important;
    }



    .main-area {
        margin-left: 0;
        padding: 1.5rem;
        padding-bottom: 5rem; /* Space for bottom nav */
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-top: 1rem;
    }

    .page-header>div:last-child {
        width: 100%;
        display: none;
    }

    h1 {
        font-size: 1.5rem;
    }
}

/* UI Elements (The "Components") */

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

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

/* Inputs & Form */
.form-group {
    margin-bottom: 2rem;
}

.label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--slate-700);
}

.input {
    width: 100%;
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background-color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--slate-900);
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.input:hover {
    border-color: var(--slate-300);
    background-color: var(--slate-50);
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12), 0 2px 4px rgba(0, 0, 0, 0.05);
}

.input::placeholder {
    color: var(--slate-400);
}

/* Custom Select */
select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 3rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    text-decoration: none;
    position: relative;
    user-select: none;
}

.btn:active {
    transform: translateY(1px) scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1), 0 2px 4px -1px rgba(59, 130, 246, 0.06);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.2), 0 4px 6px -2px rgba(59, 130, 246, 0.1);
}

.btn-outline {
    background: white;
    border: 1.5px solid var(--border);
    color: var(--slate-800);
}

.btn-outline:hover {
    background: var(--slate-50);
    border-color: var(--slate-400);
    transform: translateY(-2px);
    color: var(--primary);
}

/* Badge System */
.badge {
    padding: 0.35rem 1rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-blue {
    background: var(--p-50);
    color: var(--p-700);
}

.badge-green {
    background: #ecfdf5;
    color: #065f46;
}

.badge-red {
    background: #fef2f2;
    color: #991b1b;
}

/* Table System */
.table-container {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-container::-webkit-scrollbar {
    height: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--slate-200);
    border-radius: 10px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Force scroll on mobile if columns exceed width */
}

.table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-bottom: 2px solid var(--slate-50);
}

.table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--slate-100);
    font-size: 0.9rem;
}

/* Card Grid Components */
.card-grid-item {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.card-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px -10px rgba(0,0,0,0.1);
    border-color: var(--primary);
}

.card-grid-item .icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--p-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-grid-item .card-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--slate-50);
    display: flex;
    gap: 0.5rem;
}

/* UI Utilities */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.font-bold {
    font-weight: 700;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.mt-4 {
    margin-top: 1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-cols-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.grid-cols-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.grid-main-side {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

/* Responsive Grids */
@media (max-width: 1200px) {
    .grid-cols-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 992px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-main-side {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Modal & AJAX UI */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    overflow: hidden;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

#modal-body {
    overflow-y: auto;
    flex: 1;
}

/* Dropdown Component */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    background: var(--slate-100);
    color: var(--slate-700);
    font-size: 0.8rem;
    font-weight: 700;
    transition: var(--transition);
    user-select: none;
    text-decoration: none;
}

.dropdown-trigger:hover {
    background: var(--slate-200);
    color: var(--primary);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 1000;
    overflow: hidden;
}

[dir="rtl"] .dropdown-menu {
    right: auto;
    left: 0;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--slate-700);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--p-50);
    color: var(--primary);
}

.dropdown-item.active {
    background: var(--p-50);
    color: var(--primary);
    font-weight: 700;
}

/* Specific Language Switcher Tweak */
.lang-selector .dropdown-trigger img {
    width: 20px;
    height: 14px;
    border-radius: 2px;
}