/* ==========================================================================
   Base Styles
   ========================================================================== */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --gray-color: #6c757d;
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.15s ease-in-out;
}

* {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--dark-color);
    background-color: var(--light-color);
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: #0a58ca;
    text-decoration: underline;
}

/* ==========================================================================
   Navbar
   ========================================================================== */

.navbar {
    box-shadow: var(--box-shadow);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    transition: var(--transition);
}

.navbar-brand:hover {
    transform: translateY(-1px);
}

.navbar-toggler {
    border: none;
    padding: 0.25rem 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    margin: 0 0.125rem;
    transition: var(--transition);
}

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

.navbar-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius);
    animation: fadeIn 0.2s ease-in-out;
}

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

.dropdown-item {
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: var(--light-color);
    transform: translateX(2px);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
    max-width: 100%;
    padding: 0 1rem;
}

@media (min-width: 576px) {
    .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .container { max-width: 720px; }
}

@media (min-width: 992px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 600;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
    margin-bottom: 0;
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.table-responsive {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.table th {
    background-color: var(--light-color);
    font-weight: 600;
    border-top: none;
    white-space: nowrap;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-control, .form-select {
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.form-text {
    font-size: 0.8rem;
    color: var(--gray-color);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: var(--transition);
    border: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-group-sm > .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    font-weight: 500;
    border-radius: var(--border-radius);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: var(--light-color);
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: var(--light-color);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile First Approach */

/* Small devices (landscape phones, 576px and up) */
@media (max-width: 575.98px) {
    body {
        font-size: 0.85rem;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.25rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: var(--border-radius) !important;
        margin-bottom: 0.25rem;
    }
    
    .card-body {
        padding: 1rem 0.75rem;
    }
    
    .modal-dialog {
        margin: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (max-width: 767.98px) {
    .row {
        margin-right: -0.5rem;
        margin-left: -0.5rem;
    }
    
    .col, [class*="col-"] {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }
    
    .table-responsive {
        margin-bottom: 1rem;
    }
    
    .btn-group-sm .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (max-width: 991.98px) {
    .container {
        padding: 0 1rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (max-width: 1199.98px) {
    .table th {
        font-size: 0.8rem;
    }
    
    .btn {
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.text-truncate-custom {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .text-truncate-custom {
        max-width: 150px;
    }
}

@media (max-width: 576px) {
    .text-truncate-custom {
        max-width: 100px;
    }
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-color);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-color);
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    .dropdown,
    .modal {
        display: none !important;
    }
    
    .container {
        width: 100%;
        max-width: none;
        padding: 0;
    }
    
    .table {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ==========================================================================
   Component Specific Styles
   ========================================================================== */

/* Dashboard cards */
.dashboard-card {
    transition: var(--transition);
    cursor: pointer;
}

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

/* Status badges */
.status-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Action buttons in tables */
.table-actions .btn {
    margin: 0 0.125rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Form validation styles */
.is-invalid {
    border-color: var(--danger-color);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--danger-color);
}

/* Success animation */
.success-animation {
    animation: successPulse 0.5s ease-in-out;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive table for mobile */
@media (max-width: 768px) {
    .table-responsive-stack {
        display: block;
    }
    
    .table-responsive-stack thead {
        display: none;
    }
    
    .table-responsive-stack tbody,
    .table-responsive-stack tr,
    .table-responsive-stack td {
        display: block;
        width: 100% !important;
    }
    
    .table-responsive-stack tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        border-radius: var(--border-radius);
        padding: 10px;
    }
    
    .table-responsive-stack td {
        border: none;
        position: relative;
        padding-left: 50%;
        text-align: left;
        white-space: normal;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        font-weight: 600;
        text-align: left;
    }
}

/* Emergency accounts specific styles */
.table-danger {
    background-color: rgba(220, 53, 69, 0.1);
}

.table-danger:hover {
    background-color: rgba(220, 53, 69, 0.2);
}

.table-warning {
    background-color: rgba(255, 193, 7, 0.1);
}

.table-warning:hover {
    background-color: rgba(255, 193, 7, 0.2);
}

/* Priority indicators */
.priority-emergency {
    animation: emergencyPulse 2s infinite;
}

@keyframes emergencyPulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Enhanced badges for emergency accounts */
.badge-emergency {
    background: linear-gradient(45deg, var(--danger-color), #ff6b6b);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* Alert animations */
.alert {
    animation: slideIn 0.3s ease-out;
}

/* Responsive adjustments for emergency dashboard */
@media (max-width: 768px) {
    .dashboard-card {
        margin-bottom: 1rem;
    }
    
    .dashboard-card .card-body {
        padding: 1rem;
    }
    
    .dashboard-card h3 {
        font-size: 1.5rem;
    }
}
