/* Root Variables and Stylesheet for Ousim Hospital Clinical Portal */

:root {
    --primary-color: #0d9488; /* Teal 600 */
    --primary-light: #06b6d4; /* Cyan 500 */
    --primary-dark: #0f766e; /* Teal 700 */
    --accent-emerald: #10b981; /* Emerald 500 */
    --accent-rose: #f43f5e; /* Rose 500 */
    --accent-amber: #f59e0b; /* Amber 500 */
    
    /* Dark Theme Palette */
    --bg-gradient-start: #070d19; /* Deep Night Blue */
    --bg-gradient-end: #0f1c2e; /* Slate Blue */
    --card-bg: rgba(255, 255, 255, 0.05); /* Glass card base */
    --card-hover-bg: rgba(255, 255, 255, 0.1);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover-color: rgba(6, 182, 212, 0.4);
    
    /* Text Colors */
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #cbd5e1; /* Slate 300 */
    --text-muted: #64748b; /* Slate 500 */
    
    /* System Properties */
    --font-main: 'Cairo', sans-serif;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --glow-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --teal-glow: 0 0 20px rgba(13, 148, 136, 0.3);
}

/* Reset & Base Elements */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    padding-bottom: 90px; /* Space for bottom nav */
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
    color: inherit;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-dark);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: var(--border-radius-lg);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--glow-shadow);
}

.header-logo-container {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--teal-glow);
    flex-shrink: 0;
}

.header-logo {
    width: 32px;
    height: 32px;
}

.header-titles h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to left, #ffffff, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-titles h2 {
    font-size: 1.1rem;
    color: var(--primary-light);
    font-weight: 600;
    margin-top: 2px;
}

.header-titles p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Search Section */
.search-section {
    margin-bottom: 24px;
    transition: var(--transition-smooth);
}

.search-wrapper {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 5px 15px;
    box-shadow: var(--glow-shadow);
    transition: var(--transition-smooth);
}

.search-input-container:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

.search-icon {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
    margin-left: 10px;
}

#search-input {
    width: 100%;
    padding: 12px 10px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
}

#search-input::placeholder {
    color: var(--text-muted);
}

.search-clear-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 10px;
    display: none;
    transition: var(--transition-smooth);
}

.search-clear-btn:hover {
    color: var(--text-primary);
}

/* Search Dropdown Results */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-hover-color);
    border-radius: var(--border-radius-lg);
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 10px;
}

.search-results-dropdown.hidden {
    display: none;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.search-result-badge {
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--border-radius-sm);
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-stroke { background: rgba(13, 148, 136, 0.2); color: #2dd4bf; }
.badge-heart { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
.badge-rabies { background: rgba(244, 63, 94, 0.2); color: #fb7185; }

.search-result-content {
    flex-grow: 1;
}

.search-result-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.search-result-snippet {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.search-result-highlight {
    background: rgba(6, 182, 212, 0.25);
    color: var(--primary-light);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* Page Views System */
.page-view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.page-view.active {
    display: block;
}

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

/* Glassmorphism Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glow-shadow);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    background: var(--card-hover-bg);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.15) 0%, rgba(2, 132, 199, 0.15) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--glow-shadow);
}

.welcome-banner h3 {
    font-size: 1.2rem;
    color: var(--primary-light);
    margin-bottom: 6px;
    font-weight: 700;
}

.welcome-banner p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Category Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.category-card {
    display: flex;
    gap: 20px;
    padding: 24px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    transition: var(--transition-smooth);
}

.category-card[data-category="stroke"]::before { background: var(--primary-color); }
.category-card[data-category="heart"]::before { background: var(--secondary-color); }
.category-card[data-category="rabies"]::before { background: var(--accent-rose); }

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.category-card[data-category="stroke"]:hover { border-color: rgba(13, 148, 136, 0.4); }
.category-card[data-category="heart"]:hover { border-color: rgba(2, 132, 199, 0.4); }
.category-card[data-category="rabies"]:hover { border-color: rgba(244, 63, 94, 0.4); }

.card-icon-container {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.bg-stroke { background: rgba(13, 148, 136, 0.15); color: #2dd4bf; border: 1px solid rgba(13, 148, 136, 0.2); }
.bg-heart { background: rgba(2, 132, 199, 0.15); color: #38bdf8; border: 1px solid rgba(2, 132, 199, 0.2); }
.bg-rabies { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.2); }

.card-icon-container svg {
    width: 30px;
    height: 30px;
    transition: var(--transition-smooth);
}

.category-card:hover .card-icon-container svg {
    transform: scale(1.1) rotate(5deg);
}

.card-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-details h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.card-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.card-action-btn {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-light);
    display: inline-block;
    transition: var(--transition-smooth);
}

.category-card:hover .card-action-btn {
    transform: translateX(-5px);
    color: white;
}

/* Instructions List inside Dashboard */
.dashboard-info-section {
    padding: 24px;
}

.dashboard-info-section h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--primary-light);
    font-weight: 700;
}

.instruction-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.instruction-list li {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.instruction-list .bullet {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(6, 182, 212, 0.1);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.instruction-list strong {
    color: white;
    display: block;
    margin-bottom: 2px;
}

.instruction-list div {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Protocol View Headers */
.view-header {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--glow-shadow);
}

.view-header h2 {
    font-size: 1.3rem;
    color: white;
    font-weight: 700;
}

.view-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Module Container and Loading */
.module-container {
    min-height: 400px;
    position: relative;
}

.fallback-module-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    min-height: 300px;
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    border: 1px dashed var(--border-color);
    padding: 30px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(6, 182, 212, 0.1);
    border-top: 4px solid var(--primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fallback-module-loader p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Admin Authentication */
.admin-login-card {
    max-width: 450px;
    margin: 60px auto;
    padding: 30px;
}

.admin-login-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
    text-align: center;
}

.admin-login-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input, .form-group select, .form-group textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.15);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: var(--teal-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(13, 148, 136, 0.5);
}

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

.btn-secondary-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: var(--text-secondary);
}

.w-full {
    width: 100%;
}

.error-text {
    color: var(--accent-rose);
    font-size: 0.85rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.success-text {
    color: var(--accent-emerald);
    font-size: 0.85rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

/* Admin Dashboard Structure */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
}

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

.text-teal { background: rgba(13, 148, 136, 0.1); color: #2dd4bf; }
.text-blue { background: rgba(2, 132, 199, 0.1); color: #38bdf8; }
.text-rose { background: rgba(244, 63, 94, 0.1); color: #fb7185; }

.stat-icon-wrapper svg {
    width: 24px;
    height: 24px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: white;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Admin Charts Layout */
.admin-charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    padding: 20px;
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin-bottom: 15px;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 240px;
}

/* SVG Chart Styles */
#chart-categories-svg text, #chart-trend-svg text {
    user-select: none;
}

.chart-bar {
    transition: var(--transition-smooth);
    cursor: pointer;
}

.chart-bar:hover {
    fill-opacity: 0.85;
}

.chart-dot {
    transition: var(--transition-smooth);
    cursor: pointer;
}

.chart-dot:hover {
    r: 7;
    fill: var(--primary-light);
}

/* Feedback Section */
.admin-feedback-section {
    padding: 24px;
    margin-bottom: 24px;
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.feedback-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.admin-feedback-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-feedback-table th, .admin-feedback-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.admin-feedback-table th {
    font-weight: 700;
    color: var(--primary-light);
    background: rgba(255, 255, 255, 0.02);
}

.admin-feedback-table tbody tr {
    transition: var(--transition-smooth);
}

.admin-feedback-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.admin-feedback-table td {
    color: var(--text-secondary);
}

.admin-feedback-table .feedback-comment-cell {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-feedback-table .feedback-comment-cell:hover {
    white-space: normal;
    word-break: break-all;
}

.action-btn-danger {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.75rem;
    font-weight: 600;
}

.action-btn-danger:hover {
    background: var(--accent-rose);
    color: white;
}

/* Feedback Floating Button and Modal */
.feedback-trigger-btn {
    position: fixed;
    bottom: 95px;
    left: 20px;
    z-index: 99;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border: none;
    padding: 10px 18px;
    border-radius: 30px;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: var(--teal-glow);
    transition: var(--transition-smooth);
}

.feedback-trigger-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.4);
}

.feedback-trigger-btn svg {
    width: 18px;
    height: 18px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    width: 100%;
    max-width: 550px;
    position: relative;
    padding: 25px;
    border-color: var(--primary-light);
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: transparent;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.modal-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 6px;
}

.modal-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 35px;
    display: flex;
    justify-content: space-around;
    padding: 10px 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 999;
    transition: var(--transition-smooth);
}

.bottom-nav:hover {
    border-color: rgba(6, 182, 212, 0.2);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    transition: var(--transition-smooth);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    height: 20px;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--primary-light);
    background: rgba(6, 182, 212, 0.1);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
}

/* Footer Styling */
.app-footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

/* Responsive Rules */
@media (min-width: 768px) {
    .header-titles h1 { font-size: 1.8rem; }
    .header-titles h2 { font-size: 1.25rem; }
    .header-titles p { font-size: 0.95rem; }
    
    .bottom-nav {
        bottom: 20px;
        border-radius: 40px;
    }
}

@media (max-width: 480px) {
    .app-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        gap: 12px;
    }
    
    .header-logo-container {
        width: 50px;
        height: 50px;
    }
    
    .header-logo {
        width: 26px;
        height: 26px;
    }
    
    .header-titles h1 { font-size: 1.25rem; }
    .header-titles h2 { font-size: 0.95rem; }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .bottom-nav {
        width: 95%;
        bottom: 10px;
    }
    
    .nav-item {
        padding: 4px 8px;
    }
    
    .nav-label {
        font-size: 0.65rem;
    }
}
