/* ==========================================================================
   ARMAMIC MEDICAL HIS 4.0 - ADVANCED DESIGN SYSTEM
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-main: #0B132B;
    --bg-card: rgba(28, 37, 65, 0.7);
    --bg-card-hover: rgba(42, 54, 91, 0.8);
    --bg-sidebar: #070D1F;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(0, 242, 254, 0.3);

    --text-primary: #F0F4F8;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    /* Accents */
    --cyan: #00F2FE;
    --cyan-glow: rgba(0, 242, 254, 0.25);
    --emerald: #10B981;
    --emerald-glow: rgba(16, 185, 129, 0.25);
    --violet: #8B5CF6;
    --violet-glow: rgba(139, 92, 246, 0.25);
    --amber: #F59E0B;
    --amber-glow: rgba(245, 158, 11, 0.25);
    --rose: #F43F5E;
    --rose-glow: rgba(244, 63, 94, 0.25);

    /* Fonts & Radii */
    --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Light Theme Overrides */
body.light-theme {
    --bg-main: #F1F5F9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: #FFFFFF;
    --bg-sidebar: #0F172A;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 119, 182, 0.4);
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 0 15px var(--cyan-glow);
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-text span {
    font-size: 11px;
    color: var(--cyan);
    font-weight: 500;
}

/* Subdermal Chip Widget in Sidebar */
.chip-status-widget {
    margin: 16px;
    padding: 12px 14px;
    background: rgba(0, 242, 254, 0.05);
    border: 1px solid var(--cyan-glow);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.chip-status-widget:hover {
    background: rgba(0, 242, 254, 0.12);
    border-color: var(--cyan);
    transform: translateY(-2px);
}

.chip-icon {
    width: 36px;
    height: 36px;
    background: var(--cyan);
    color: #000;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chip-icon.pulse {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 242, 254, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
}

.chip-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chip-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.chip-info strong {
    font-size: 12px;
    color: var(--cyan);
}

.chip-signal {
    color: var(--cyan);
    font-size: 14px;
}

/* Nav Menu */
.nav-menu {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 16px 12px 6px 12px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(0, 242, 254, 0.15), transparent);
    color: var(--cyan);
    border-right: 3px solid var(--cyan);
    font-weight: 700;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--cyan);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details strong {
    font-size: 13px;
}

.user-details span {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Top Header */
.top-header {
    height: 70px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(11, 19, 43, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 6px 16px;
    width: 450px;
    transition: var(--transition);
}

.header-search:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 12px var(--cyan-glow);
}

.header-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
    font-family: var(--font-family);
    font-size: 13px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-clock {
    font-family: monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--cyan);
    background: rgba(0, 242, 254, 0.08);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--cyan-glow);
}

/* Tab Sections */
.tab-content {
    display: none;
    padding: 28px;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

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

/* Page Title Bar */
.page-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title-bar h2 {
    font-size: 22px;
    font-weight: 800;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--cyan), #00A8FF);
    color: #000;
    box-shadow: 0 4px 14px var(--cyan-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--cyan-glow);
}

.btn-emerald {
    background: linear-gradient(135deg, var(--emerald), #059669);
    color: #fff;
    box-shadow: 0 4px 14px var(--emerald-glow);
}

.btn-emerald:hover {
    transform: translateY(-2px);
}

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

.btn-outline:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-icon:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* Cards & Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
}

.metric-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.metric-card.cyan .metric-icon { background: rgba(0, 242, 254, 0.15); color: var(--cyan); }
.metric-card.emerald .metric-icon { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.metric-card.violet .metric-icon { background: rgba(139, 92, 246, 0.15); color: var(--violet); }
.metric-card.amber .metric-icon { background: rgba(245, 158, 11, 0.15); color: var(--amber); }

.metric-body {
    display: flex;
    flex-direction: column;
}

.metric-body span {
    font-size: 12px;
    color: var(--text-secondary);
}

.metric-body h3 {
    font-size: 22px;
    font-weight: 800;
    margin: 2px 0;
}

.trend {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend.up { color: var(--emerald); }
.trend.down { color: var(--cyan); }
.trend.warning { color: var(--amber); }

/* Layout Grids */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.card-grid-3 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

.span-2 { grid-column: span 1; }

.panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h3 i {
    color: var(--cyan);
}

/* Data Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: right;
}

.data-table th {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.badge-emerald { background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-cyan { background: rgba(0, 242, 254, 0.15); color: var(--cyan); border: 1px solid rgba(0, 242, 254, 0.3); }
.badge-violet { background: rgba(139, 92, 246, 0.15); color: var(--violet); border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-info { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* Subdermal Chip Visual Box */
.chip-scan-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chip-visual {
    height: 140px;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.05), rgba(139, 92, 246, 0.05));
    border: 2px dashed var(--cyan-glow);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--cyan);
}

.chip-visual i {
    font-size: 36px;
    animation: bouncePulse 2s infinite;
}

@keyframes bouncePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.chip-details-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
}

/* DICOM Viewer */
.dicom-viewer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dicom-screen {
    height: 300px;
    background: #000;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.dicom-screen img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: filter 0.3s;
}

.dicom-screen.inverted img {
    filter: invert(1);
}

.dicom-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: monospace;
    font-size: 11px;
    color: var(--emerald);
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.dicom-controls {
    display: flex;
    gap: 8px;
}

/* Forms & Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

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

.form-control {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px var(--cyan-glow);
}

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

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input { flex: 1; }

/* Beds Matrix Grid */
.beds-visual-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.bed-tile {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.bed-tile:hover {
    transform: translateY(-2px);
    border-color: var(--cyan);
}

.bed-tile i {
    font-size: 22px;
}

.bed-tile.occupied { border-color: var(--rose); }
.bed-tile.occupied i { color: var(--rose); }
.bed-tile.available { border-color: var(--emerald); }
.bed-tile.available i { color: var(--emerald); }
.bed-tile.reserved { border-color: var(--amber); }
.bed-tile.reserved i { color: var(--amber); }

.bed-number {
    font-size: 12px;
    font-weight: 700;
}

/* Indoor Map Canvas */
.map-canvas-container {
    background: #050B18;
    border-radius: var(--radius-md);
    padding: 10px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

canvas {
    border-radius: var(--radius-sm);
    max-width: 100%;
}

/* Genetic Tree Box */
.genetic-tree-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.tree-node-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.gene-node {
    background: var(--bg-card);
    border: 2px solid var(--violet);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: 0 0 15px var(--violet-glow);
}

.gene-node strong {
    display: block;
    font-size: 13px;
}

.gene-node small {
    font-size: 10px;
    color: var(--text-secondary);
}

/* AI Assistant Chat */
.ai-chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    height: 520px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-bubble {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.chat-bubble.ai {
    align-self: flex-start;
}

.chat-bubble.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chat-text {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.6;
}

.chat-bubble.user .chat-text {
    background: var(--cyan);
    color: #000;
    font-weight: 500;
}

.ai-chat-input {
    padding: 14px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.ai-chat-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    color: var(--text-primary);
    outline: none;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.gallery-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.gallery-card:hover {
    transform: scale(1.03);
    border-color: var(--cyan);
}

.gallery-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.gallery-info {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
}

.gallery-info strong {
    font-size: 12px;
}

.gallery-info span {
    font-size: 10px;
    color: var(--text-muted);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

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

.modal-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--cyan-glow);
    border-radius: var(--radius-lg);
    width: 540px;
    max-width: 90%;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.close-btn:hover { color: var(--rose); }

/* Label Printer Preview */
.label-preview-card {
    margin-top: 16px;
    background: #FFF;
    color: #000;
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 2px dashed #000;
}

.qr-placeholder {
    width: 64px;
    height: 64px;
    background: #000;
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border-radius: var(--radius-sm);
}

.nfc-chip-tag {
    font-size: 10px;
    font-weight: 700;
    color: var(--emerald);
    margin-top: 4px;
}

.margin-top-sm { margin-top: 8px; }
.margin-top-md { margin-top: 16px; }

/* Responsive Media Queries */
@media (max-width: 992px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .dashboard-grid, .card-grid-3 { grid-template-columns: 1fr; }
    .header-search { width: 100%; }
}
