/**
 * SAMARITAN PORTAL - Global Styles (Optimized)
 * Green-Blue gradient theme with true liquid responsive design
 * 
 * Changelog:
 * - Removed all duplicate definitions
 * - Unified container system for liquid layout
 * - Minimized !important usage
 * - Fixed conflicting styles
 * - Maintained Bootstrap compatibility
 */

/* ============================================
   CSS VARIABLES / DESIGN TOKENS
   ============================================ */
:root {
    /* Brand Colors */
    --brand1: #00c6ff;  /* Blue */
    --brand2: #00d26a;  /* Green */
    
    /* Background Colors */
    --bg: #f8fafc;
    --bg-dark: #0f172a;
    --card: #ffffff;
    --card-hover: #f1f5f9;
    
    /* Text Colors */
    --text: #1e293b;
    --text-light: #64748b;
    --text-dark: #0f172a;
    
    /* Status Colors */
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    /* Borders & Shadows */
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Layout Variables (Unified) */
    --header-height: 64px;
    --gutter-min: 12px;
    --gutter-preferred: 3vw;
    --gutter-max: 36px;
    --gutter: clamp(var(--gutter-min), var(--gutter-preferred), var(--gutter-max));
    --content-max-width: 100%; /* True liquid by default */
    --content-reading-max: 1320px; /* Optional constraint for readability */
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Smooth scrolling and better text rendering */
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
    /* Dynamic body padding for fixed header */
    padding-top: 0;
}

/* Fixed header spacing - Desktop only */
@media (min-width: 992px) {
    body.has-fixed-header {
        padding-top: calc(var(--header-height) + 12px);
    }
}

/* ============================================
   LIQUID LAYOUT SYSTEM (Unified)
   ============================================ */
   
/* Primary liquid container - use this for all pages */
.sp-container {
    width: 100%;
    padding-inline: var(--gutter);
    margin-inline: auto;
}

/* Optional width constraints (only when needed) */
.sp-container--reading {
    max-width: var(--content-reading-max);
}

.sp-container--wide {
    max-width: 1440px;
}

.sp-container--full {
    max-width: 100%;
    padding-inline: var(--gutter);
}

/* Content wrapper for consistent spacing */
.content-wrapper {
    padding-top: 8px;
}

.content-wrapper > :first-child {
    margin-top: 0;
}

/* Page header component */
.page-header {
    margin-block: 1rem 1.5rem;
}

@media (min-width: 992px) {
    .page-header {
        margin-block: 1.25rem 1.75rem;
    }
}

/* ============================================
   GRADIENT BACKGROUNDS
   ============================================ */
.gradient-bg {
    background: linear-gradient(135deg, var(--brand1) 0%, var(--brand2) 100%);
}

.gradient-text {
    background: linear-gradient(135deg, var(--brand1) 0%, var(--brand2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.animated-gradient {
    background: linear-gradient(270deg, var(--brand1), var(--brand2), var(--brand1));
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Optional multi-color gradient */
.gradient-bg-multi {
    background: linear-gradient(135deg, 
        #00b050 0%,   /* Green */
        #0070c0 25%,  /* Blue */
        #ffc000 50%,  /* Yellow */
        #e31e24 75%,  /* Red */
        #7030a0 100%  /* Purple */
    );
}

/* ============================================
   NAVIGATION & HEADER
   ============================================ */
   
/* Desktop layout: brand | centered nav | user */
@media (min-width: 992px) {
    .sp-navbar .container-fluid {
        display: flex;
        align-items: center;
    }
    
    #memberNavbar {
        display: flex !important;
        flex: 1 1 auto;
        align-items: center;
    }
    
    .sp-nav-center {
        flex: 1 1 0;
        display: flex;
        justify-content: center;
    }
    
    .sp-nav-center .navbar-nav {
        gap: 8px;
    }
    
    .sp-user {
        margin-left: auto;
        display: flex;
        align-items: center;
    }
}

/* Icon-only mobile nav */
.navbar .nav-link .nav-icon {
    display: inline-flex;
    line-height: 1;
}

.navbar .nav-link .nav-icon svg {
    width: 1.35rem;
    height: 1.35rem;
}

.navbar .nav-link .nav-icon i {
    font-size: 1.35rem;
}

.navbar .nav-link .nav-label {
    display: inline-block;
    margin-left: 0.5rem;
    white-space: nowrap;
}

/* Mobile nav: icon-only, centered */
@media (max-width: 991.98px) {
    .navbar .navbar-nav {
        width: 100%;
        justify-content: space-between;
    }
    
    .navbar .navbar-nav .nav-link {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        padding: 0.5rem 0.75rem;
    }
    
    .navbar .nav-link .nav-icon svg {
        width: 1.6rem;
        height: 1.6rem;
    }
    
    .navbar .nav-link .nav-icon i {
        font-size: 1.6rem;
    }
    
    .navbar .nav-link .nav-label {
        /* Accessibly hide labels on mobile */
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* Nav link states */
.navbar .nav-link.active .nav-icon,
.navbar .nav-link:focus .nav-icon,
.navbar .nav-link:hover .nav-icon {
    opacity: 0.9;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-xl);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand1) 0%, var(--brand2) 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 198, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 198, 255, 0.4);
}

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--brand1);
    color: var(--brand1);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-danger {
    background: var(--error);
    color: #ffffff;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--card);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
    color: var(--text-dark);
}

.card-body {
    color: var(--text-light);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand1);
    box-shadow: 0 0 0 3px rgba(0, 198, 255, 0.1);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
}

/* ============================================
   TABLES (Liquid/Responsive)
   ============================================ */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    /* Allow horizontal scroll on small screens */
    -webkit-overflow-scrolling: touch;
}

.resp-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    table-layout: auto; /* Allow natural column sizing */
}

.resp-table thead {
    background: linear-gradient(135deg, var(--brand1) 0%, var(--brand2) 100%);
    color: #ffffff;
}

.resp-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

.resp-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.resp-table tbody tr:hover {
    background: var(--card-hover);
}

.resp-table tbody tr:last-child td {
    border-bottom: none;
}

/* Stack table on mobile for better UX */
@media (max-width: 900px) {
    .resp-table thead {
        display: none;
    }
    
    .resp-table,
    .resp-table tbody,
    .resp-table tr,
    .resp-table td {
        display: block;
        width: 100%;
    }
    
    .resp-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        overflow: hidden;
    }
    
    .resp-table td {
        position: relative;
        padding-left: 50%;
        text-align: right;
    }
    
    .resp-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        padding-right: 0.5rem;
        text-align: left;
        font-weight: 600;
        color: var(--text-dark);
    }
}

/* ============================================
   BADGES & STATUS
   ============================================ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
    text-transform: capitalize;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash-message {
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   MODALS
   ============================================ */
.mm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.mm-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mm-modal-content {
    background: var(--card);
    border-radius: var(--radius-2xl);
    padding: var(--space-xl);
    max-width: min(500px, 90vw);
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPop 0.3s ease;
}

@keyframes modalPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.mm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.mm-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.3s ease;
}

.mm-modal-close:hover {
    color: var(--error);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin: 2rem 0;
}

.page-btn,
.page-num {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    transition: all 0.3s ease;
}

.page-btn:hover,
.page-num:hover {
    border-color: var(--brand1);
    color: var(--brand1);
}

.page-num.active {
    background: linear-gradient(135deg, var(--brand1) 0%, var(--brand2) 100%);
    color: #ffffff;
    border-color: transparent;
}

/* ============================================
   GRID SYSTEM (Liquid/Responsive)
   ============================================ */
.grid {
    display: grid;
    gap: var(--space-lg);
    width: 100%;
}

/* Auto-responsive grid */
.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

/* Fixed column grids with responsive breakpoints */
.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

/* Force single column on mobile */
@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
   
/* Text alignment */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-justify { text-align: justify; }

/* Text styles */
.text-bold { font-weight: 600; }
.text-normal { font-weight: 400; }
.text-light { font-weight: 300; }
.text-muted { color: var(--text-light); }
.text-small { font-size: 0.875rem; }
.text-large { font-size: 1.125rem; }

/* Margins (using logical properties) */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mx-auto { margin-inline: auto; }
.my-1 { margin-block: 0.5rem; }
.my-2 { margin-block: 1rem; }
.my-3 { margin-block: 1.5rem; }

/* Padding (using logical properties) */
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.px-1 { padding-inline: 0.5rem; }
.px-2 { padding-inline: 1rem; }
.px-3 { padding-inline: 1.5rem; }

.py-1 { padding-block: 0.5rem; }
.py-2 { padding-block: 1rem; }
.py-3 { padding-block: 1.5rem; }

/* Flexbox utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* Display utilities */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }

/* Responsive display utilities */
@media (max-width: 768px) {
    .hide-mobile { display: none; }
    .show-mobile { display: block; }
}

@media (min-width: 769px) and (max-width: 991px) {
    .hide-tablet { display: none; }
    .show-tablet { display: block; }
}

@media (min-width: 992px) {
    .hide-desktop { display: none; }
    .show-desktop { display: block; }
}

/* Width utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-screen { width: 100vw; }

/* Height utilities */
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.h-auto { height: auto; }

/* Overflow utilities */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-scroll { overflow: scroll; }
.overflow-x-auto { overflow-x: auto; overflow-y: hidden; }
.overflow-y-auto { overflow-y: auto; overflow-x: hidden; }

/* Position utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.static { position: static; }

/* Z-index utilities */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Border utilities */
.border { border: 1px solid var(--border); }
.border-0 { border: 0; }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-l { border-left: 1px solid var(--border); }
.border-r { border-right: 1px solid var(--border); }

.rounded { border-radius: var(--radius-md); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: 9999px; }

/* Shadow utilities */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }

/* ============================================
   ACCESSIBILITY
   ============================================ */
   
/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--brand1);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--brand1);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-main:focus {
    top: 0;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    /* Hide navigation and non-essential elements */
    .navbar,
    .sp-navbar,
    .mm-modal,
    .pagination,
    .no-print {
        display: none !important;
    }
    
    /* Reset colors for print */
    body {
        background: white;
        color: black;
    }
    
    /* Ensure content fits on page */
    .sp-container {
        max-width: 100%;
        padding: 0;
    }
    
    /* Avoid page breaks inside elements */
    .card,
    .resp-table tr {
        page-break-inside: avoid;
    }
}

/* ============================================
   ANIMATIONS & TRANSITIONS
   ============================================ */
   
/* Smooth transitions for interactive elements */
a,
button,
input,
select,
textarea {
    transition: all 0.3s ease;
}

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Slide up animation */
@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ============================================
   CUSTOM SCROLLBAR (Webkit browsers)
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: var(--radius-lg);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    border-radius: var(--radius-lg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand1);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--brand1) var(--bg);
}