:root {
    --primary-color: #28a745;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --info-color: #6c757d;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --accent-color: #dc3545;
    --gray-color: #6c757d;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #e9ecef;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-wrapper {
    flex: 1;
    padding: 20px 0;
}

/* Boxed Container */
.boxed-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

/* Login Page Styles */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 50%, #6c757d 100%);
}

.login-box {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-box .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-box .logo i {
    font-size: 60px;
    color: var(--primary-color);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark-color);
}

/* Dashboard Cards */
.dashboard-card {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
    border: none;
    height: 100%;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.dashboard-card .icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 35px;
}

.dashboard-card .icon.primary { background: rgba(40, 167, 69, 0.1); color: var(--primary-color); }
.dashboard-card .icon.success { background: rgba(40, 167, 69, 0.1); color: var(--success-color); }
.dashboard-card .icon.info { background: rgba(108, 117, 125, 0.1); color: var(--gray-color); }
.dashboard-card .icon.warning { background: rgba(220, 53, 69, 0.1); color: var(--danger-color); }
.dashboard-card .icon.danger { background: rgba(220, 53, 69, 0.1); color: var(--danger-color); }
.dashboard-card .icon.secondary { background: rgba(108, 117, 125, 0.1); color: var(--secondary-color); }

.dashboard-card h4 {
    color: var(--dark-color);
    margin-bottom: 10px;
}

.dashboard-card p {
    color: var(--secondary-color);
    margin-bottom: 0;
}

/* Form Styles */
.form-section {
    background: #fff;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-section h5 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* Bold Labels Everywhere */
.form-label, label {
    font-weight: 600 !important;
    color: var(--dark-color);
    margin-bottom: 0.4rem;
}

/* Mixed Green/Red Card Headers */
.card-header.bg-danger { background: linear-gradient(135deg, #dc3545, #c82333) !important; }
.card-header.bg-success { background: linear-gradient(135deg, #28a745, #1e7e34) !important; }
.card-header.bg-mixed-1 { background: linear-gradient(135deg, #28a745, #20c997) !important; color: white; }
.card-header.bg-mixed-2 { background: linear-gradient(135deg, #dc3545, #e83e8c) !important; color: white; }

/* Accent borders for visual appeal */
.card { border: none; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.card-header { border-bottom: none; }

/* Green/Red section dividers */
.section-divider-green { border-left: 4px solid #28a745; padding-left: 15px; }
.section-divider-red { border-left: 4px solid #dc3545; padding-left: 15px; }

/* Table Styles */
.table-container {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.table thead th {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 15px 10px;
}

.table tbody tr:hover {
    background-color: rgba(40, 167, 69, 0.05);
}

/* Patient Card */
.patient-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    overflow: hidden;
}

.patient-card-header {
    background: linear-gradient(135deg, var(--primary-color), #1e7e34);
    color: #fff;
    padding: 15px 20px;
}

.patient-card-body {
    padding: 20px;
}

.patient-info-row {
    display: flex;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
}

.patient-info-row:last-child {
    border-bottom: none;
}

.patient-info-label {
    font-weight: 600;
    color: var(--secondary-color);
    min-width: 150px;
}

.patient-info-value {
    color: var(--dark-color);
}

/* Filter Section */
.filter-section {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Print Layout Designer */
.layout-field {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 10px;
    cursor: move;
    transition: all 0.2s;
}

.layout-field:hover {
    border-color: var(--primary-color);
    background: rgba(40, 167, 69, 0.05);
}

.layout-field.active {
    border-color: var(--success-color);
    background: rgba(40, 167, 69, 0.1);
}

.layout-zone {
    min-height: 150px;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.layout-zone h6 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* Print Styles */
@media print {
    body {
        background: #fff !important;
    }
    
    .navbar, .footer, .no-print, .filter-section {
        display: none !important;
    }
    
    .main-wrapper {
        padding: 0 !important;
    }
    
    .boxed-container {
        box-shadow: none !important;
        max-width: 100% !important;
        padding: 20px !important;
    }
    
    .print-area {
        width: 210mm;
        min-height: 297mm;
        padding: 20mm;
        margin: 0 auto;
        background: #fff;
    }
    
    .print-header {
        text-align: center;
        border-bottom: 2px solid #000;
        padding-bottom: 15px;
        margin-bottom: 20px;
    }
    
    .print-content {
        font-size: 12pt;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
    }
    
    .print-table th, .print-table td {
        border: 1px solid #000;
        padding: 8px;
        text-align: left;
    }
    
    .print-table th {
        background: #f0f0f0;
    }
    
    .page-break {
        page-break-before: always;
    }
}

/* Diet Chart Styles */
.diet-chart-table {
    width: 100%;
}

.diet-chart-table th {
    background: var(--primary-color);
    color: #fff;
    padding: 12px;
    width: 30%;
}

.diet-chart-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

/* Modal Styles */
.modal-header {
    background: linear-gradient(135deg, var(--primary-color), #1e7e34);
    color: #fff;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .boxed-container {
        margin: 10px;
        padding: 15px;
    }
    
    .dashboard-card {
        margin-bottom: 15px;
    }
    
    .patient-info-row {
        flex-direction: column;
    }
    
    .patient-info-label {
        margin-bottom: 5px;
    }
}

/* Badge Styles */
.badge-tehreek, .badge-pulse {
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 500;
}

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

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

/* Custom Button Colors */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-primary:hover {
    background-color: #1e7e34 !important;
    border-color: #1e7e34 !important;
}

.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

.btn-danger {
    background-color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
}

.btn-outline-danger {
    color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
}

.btn-outline-danger:hover {
    background-color: var(--danger-color) !important;
    color: #fff !important;
}

.btn-secondary {
    background-color: var(--gray-color) !important;
    border-color: var(--gray-color) !important;
}

/* Navbar Styling */
.navbar {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
}

.navbar-brand, .nav-link {
    color: #fff !important;
}

.nav-link:hover {
    color: rgba(255,255,255,0.8) !important;
}

.navbar-nav .nav-link {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0.9rem;
}

/* Form Focus States */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Link Colors */
a {
    color: var(--primary-color);
}

a:hover {
    color: #1e7e34;
}

/* Alert styling */
.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    border-color: var(--primary-color);
    color: #1e7e34;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: var(--danger-color);
    color: #c82333;
}

/* Badge styling */
.badge.bg-primary {
    background-color: var(--primary-color) !important;
}

.badge.bg-danger {
    background-color: var(--danger-color) !important;
}

.badge.bg-secondary {
    background-color: var(--gray-color) !important;
}

/* Print buttons bar */
.print-btn-bar {
    background: #343a40;
    padding: 8px 15px;
    border-radius: 5px;
    display: inline-flex;
    gap: 5px;
}

.print-btn-bar .btn {
    padding: 5px 15px;
    font-size: 14px;
}

/* Nav Tabs Styling - Green Theme */
.nav-tabs {
    border-bottom: 2px solid var(--primary-color);
}

.nav-tabs .nav-link {
    background-color: var(--primary-color) !important;
    color: #fff !important;
    border: 1px solid var(--primary-color) !important;
    border-bottom: none !important;
    margin-right: 3px;
    border-radius: 5px 5px 0 0 !important;
    padding: 8px 16px;
    font-weight: 500;
}

.nav-tabs .nav-link:hover {
    background-color: #1e7e34 !important;
    border-color: #1e7e34 !important;
    color: #fff !important;
}

.nav-tabs .nav-link.active {
    background-color: #fff !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) var(--primary-color) #fff !important;
    font-weight: 600;
}

/* Fix dropdown menu clipping ONLY for tables with dropdowns */
/* Use overflow-x: auto for horizontal scrolling, overflow-y: visible for dropdowns */
.table-responsive.has-dropdowns {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
}

/* Ensure dropdowns appear above table content */
.table .dropdown-menu {
    z-index: 1050;
    position: fixed;
}

/* Alternative: use fixed positioning for dropdown menus inside scrollable tables */
@media (min-width: 768px) {
    .table-responsive:not(.has-dropdowns) {
        overflow-x: auto;
    }
}

/* Mobile: allow horizontal scrolling for tables */
@media (max-width: 767.98px) {
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Dropdowns use fixed positioning on mobile */
    .table .dropdown-menu {
        position: fixed;
        max-height: 50vh;
        overflow-y: auto;
    }
}

/* ==========================================
   MOBILE RESPONSIVE STYLES
   ========================================== */

/* Mobile-first responsive container */
@media (max-width: 767.98px) {
    .main-wrapper {
        padding: 10px 0;
    }
    
    .boxed-container {
        margin: 0 10px;
        padding: 15px;
        border-radius: 8px;
    }
    
    /* Dashboard cards on mobile */
    .dashboard-card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .dashboard-card .icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
        margin-bottom: 15px;
    }
    
    .dashboard-card h4 {
        font-size: 1rem;
    }
    
    /* Page titles */
    h1, .h1 {
        font-size: 1.5rem;
    }
    
    h2, .h2 {
        font-size: 1.3rem;
    }
    
    h3, .h3 {
        font-size: 1.1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-group {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    /* Forms */
    .form-section {
        padding: 15px;
    }
    
    .form-section .section-title {
        font-size: 1rem;
        padding: 10px 15px;
        margin: -15px -15px 15px -15px;
    }
    
    /* Action buttons */
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    /* Tables - make them horizontally scrollable */
    .table-responsive-mobile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack table cells on very small screens */
    .table-stack-mobile thead {
        display: none;
    }
    
    .table-stack-mobile tbody tr {
        display: block;
        border: 1px solid #dee2e6;
        margin-bottom: 10px;
        border-radius: 5px;
        padding: 10px;
    }
    
    .table-stack-mobile tbody td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #eee;
    }
    
    .table-stack-mobile tbody td:last-child {
        border-bottom: none;
    }
    
    .table-stack-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary-color);
        margin-right: 10px;
    }
    
    /* Print button bar */
    .print-btn-bar {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* Nav tabs on mobile */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.875rem;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 10px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* Search and filter bars */
    .search-filter-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-filter-bar .form-control,
    .search-filter-bar .form-select {
        width: 100%;
    }
    
    /* Spacing adjustments */
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .mt-4 {
        margin-top: 1rem !important;
    }
    
    .p-4 {
        padding: 1rem !important;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991.98px) {
    .boxed-container {
        margin: 0 15px;
        padding: 20px;
    }
    
    .dashboard-card {
        padding: 25px;
    }
}

/* Ensure tables are always scrollable on mobile */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Touch-friendly targets */
@media (max-width: 767.98px) {
    .btn, 
    .nav-link, 
    .dropdown-item,
    .form-check-input {
        min-height: 44px;
    }
    
    .form-check-label {
        padding-left: 8px;
        line-height: 44px;
    }
}

/* Print preview mobile adjustments */
@media (max-width: 767.98px) {
    .print-preview-container {
        padding: 10px;
    }
    
    .print-preview-container iframe {
        min-height: 400px;
    }
}

/* Login page mobile */
@media (max-width: 575.98px) {
    .login-box {
        margin: 15px;
        padding: 25px;
    }
    
    .login-box .logo i {
        font-size: 45px;
    }
    
    .login-box h2 {
        font-size: 1.25rem;
        margin-bottom: 20px;
    }
}

/* Patient profile mobile */
@media (max-width: 767.98px) {
    .patient-info-grid {
        grid-template-columns: 1fr;
    }
    
    .patient-photo {
        max-width: 150px;
        margin: 0 auto 15px;
    }
}

/* ==========================================
   Prescription Grid Layout (Bootstrap-based)
   ========================================== */

/* Medicine row styling */
.medicine-row {
    background: #fafafa;
    transition: background-color 0.2s ease;
}

.medicine-row:hover {
    background: #f0f0f0;
}

/* Serial number badge - positioned in corner */
.medicine-row .serial-num {
    position: absolute;
    top: -5px;
    left: -5px;
    z-index: 1;
    font-size: 9px;
    border-radius: 4px;
    padding: 2px 4px;
}

/* Mobile labels styling */
.medicine-row label {
    display: block;
    margin-bottom: 2px;
    font-size: 0.75rem;
}

/* Autocomplete results for prescription grid */
.medicine-row .autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.medicine-row .autocomplete-results .autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.medicine-row .autocomplete-results .autocomplete-item:hover {
    background: #f5f5f5;
}

.medicine-row .autocomplete-results .autocomplete-item:last-child {
    border-bottom: none;
}
