/* ========================================
   CTFX Cargo Management System - Main Styles
   ======================================== */

/* ========================================
   1. CSS Variables & Theme Colors
   ======================================== */
:root {
    /* Brand Colors - Orange primary, white/gray backgrounds */
    --ctfx-primary: #F7941D;        /* Orange - Primary CTAs */
    --ctfx-primary-hover: #E68A1A;  /* Darker orange for hover */
    --ctfx-primary-light: #FFF3E6;  /* Very light orange for backgrounds */

    /* Semantic Colors */
    --ctfx-success: #28a745;
    --ctfx-danger: #dc3545;
    --ctfx-warning: #ffc107;
    --ctfx-info: #17a2b8;

    /* Neutral Colors */
    --ctfx-white: #ffffff;
    --ctfx-gray-50: #fafafa;
    --ctfx-gray-100: #f8f9fa;
    --ctfx-gray-200: #e9ecef;
    --ctfx-gray-300: #dee2e6;
    --ctfx-gray-400: #ced4da;
    --ctfx-gray-500: #adb5bd;
    --ctfx-gray-600: #6c757d;
    --ctfx-gray-700: #495057;
    --ctfx-gray-800: #343a40;
    --ctfx-gray-900: #212529;

    /* Typography */
    --ctfx-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ctfx-font-size-base: 1rem;
    --ctfx-line-height-base: 1.5;

    /* Layout */
    --ctfx-sidebar-width: 260px;
    --ctfx-navbar-height: 60px;

    /* Shadows */
    --ctfx-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --ctfx-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --ctfx-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

    /* Border Radius */
    --ctfx-border-radius: 0.375rem;
    --ctfx-border-radius-lg: 0.5rem;
}

/* ========================================
   2. Base Styles
   ======================================== */
html {
    height: 100%;
}

body {
    min-height: 100%;
    font-family: var(--ctfx-font-family);
    font-size: var(--ctfx-font-size-base);
    line-height: var(--ctfx-line-height-base);
    color: var(--ctfx-gray-900);
    background-color: var(--ctfx-gray-50);
}

/* ========================================
   3. Sidebar Layout (Desktop - Left Side)
   ======================================== */
#wrapper {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--ctfx-sidebar-width);
    background-color: var(--ctfx-white);
    border-right: 1px solid var(--ctfx-gray-200);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

/* Hide sidebar on mobile */
@media (max-width: 991.98px) {
    .sidebar {
        display: none;
    }
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--ctfx-gray-200);
    text-align: center;
    background-color: var(--ctfx-gray-50);
}

.sidebar-logo-img {
    max-width: 220px;
    height: auto;
    display: block;
    margin: 0 auto 0 auto;
    padding-right: 0.75rem;
}

.sidebar-logo {
    font-size: 2.5rem;
    color: var(--ctfx-primary);
    display: block;
    margin-bottom: 0.5rem;
}

.sidebar-brand {
    margin: 0;
    font-weight: 700;
    color: var(--ctfx-gray-900);
    font-size: 1.25rem;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: var(--ctfx-gray-700);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link i {
    font-size: 1.25rem;
    width: 1.5rem;
    margin-right: 0.75rem;
}

.sidebar-link:hover {
    background-color: var(--ctfx-primary-light);
    color: var(--ctfx-primary);
    border-left-color: var(--ctfx-primary);
}

.sidebar-link.active {
    background-color: var(--ctfx-primary-light);
    color: var(--ctfx-primary);
    border-left-color: var(--ctfx-primary);
    font-weight: 600;
}

.sidebar-link.text-danger {
    color: var(--ctfx-danger);
}

.sidebar-link.text-danger:hover {
    background-color: #ffebee;
    border-left-color: var(--ctfx-danger);
}

.sidebar-footer {
    padding: 1rem 0;
    border-top: 1px solid var(--ctfx-gray-200);
}

/* ========================================
   4. Mobile Offcanvas Sidebar (Right Side)
   ======================================== */
.mobile-sidebar-menu {
    padding: 0;
}

.mobile-sidebar-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--ctfx-gray-700);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.mobile-sidebar-link i {
    font-size: 1.25rem;
    width: 1.5rem;
    margin-right: 0.75rem;
}

.mobile-sidebar-link:hover {
    background-color: var(--ctfx-primary-light);
    color: var(--ctfx-primary);
    border-left-color: var(--ctfx-primary);
}

.mobile-sidebar-link.active {
    background-color: var(--ctfx-primary-light);
    color: var(--ctfx-primary);
    border-left-color: var(--ctfx-primary);
    font-weight: 600;
}

.mobile-sidebar-link.text-danger {
    color: var(--ctfx-danger);
}

.mobile-sidebar-link.text-danger:hover {
    background-color: #ffebee;
    border-left-color: var(--ctfx-danger);
}

/* ========================================
   5. Page Content Wrapper
   ======================================== */
#page-content-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Offset for sidebar on desktop */
@media (min-width: 992px) {
    #page-content-wrapper {
        margin-left: var(--ctfx-sidebar-width);
        width: calc(100% - var(--ctfx-sidebar-width));
    }
}

/* ========================================
   6. Top Navbar (White Background)
   ======================================== */
.navbar {
    background-color: var(--ctfx-white);
    box-shadow: var(--ctfx-shadow-sm);
    min-height: var(--ctfx-navbar-height);
}

.navbar .btn-link {
    text-decoration: none;
    padding: 0.5rem;
}

.navbar-text {
    color: var(--ctfx-gray-700);
    font-size: 0.9rem;
}

.navbar-brand {
    font-weight: 700;
    color: var(--ctfx-gray-900);
}

/* ========================================
   7. Main Content Areas
   ======================================== */
.main-content {
    flex: 1;
    padding: 2rem;
    background-color: var(--ctfx-gray-50);
}

.main-content-unauthenticated {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background-color: var(--ctfx-gray-50);
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
}

/* ========================================
   8. Cards & Panels
   ======================================== */
.card {
    border: none;
    border-radius: var(--ctfx-border-radius-lg);
    box-shadow: var(--ctfx-shadow-sm);
    margin-bottom: 1.5rem;
    background-color: var(--ctfx-white);
}

.card-header {
    background-color: var(--ctfx-white);
    border-bottom: 2px solid var(--ctfx-gray-200);
    font-weight: 600;
    padding: 1rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Auth Card (Login/Register) */
.auth-card {
    max-width: 450px;
    width: 100%;
    background: var(--ctfx-white);
    border-radius: var(--ctfx-border-radius-lg);
    box-shadow: var(--ctfx-shadow);
    overflow: hidden;
}

.auth-card-header {
    background: linear-gradient(135deg, var(--ctfx-primary) 0%, var(--ctfx-primary-hover) 100%);
    color: var(--ctfx-white);
    padding: 2rem;
    text-align: center;
}

.auth-card-header .logo {
    font-size: 2.5rem;
    color: var(--ctfx-white);
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.auth-card-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--ctfx-white);
}

.auth-card-body {
    padding: 2rem;
}

.auth-card-footer {
    background-color: var(--ctfx-gray-100);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--ctfx-gray-600);
}

/* ========================================
   9. Buttons
   ======================================== */
.btn {
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: var(--ctfx-border-radius);
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--ctfx-primary);
    border-color: var(--ctfx-primary);
    color: var(--ctfx-white);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--ctfx-primary-hover);
    border-color: var(--ctfx-primary-hover);
    color: var(--ctfx-white);
}

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

.btn-outline-primary:hover {
    background-color: var(--ctfx-primary);
    border-color: var(--ctfx-primary);
    color: var(--ctfx-white);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ========================================
   10. Forms
   ======================================== */
.form-label {
    font-weight: 600;
    color: var(--ctfx-gray-800);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control,
.form-select {
    border: 1px solid var(--ctfx-gray-300);
    border-radius: var(--ctfx-border-radius);
    padding: 0.625rem 0.875rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ctfx-primary);
    box-shadow: 0 0 0 0.2rem rgba(247, 148, 29, 0.25);
}

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

.invalid-feedback {
    display: block;
    font-size: 0.875rem;
}

/* ========================================
   11. Tables
   ======================================== */
.table {
    margin-bottom: 0;
    background-color: var(--ctfx-white);
}

.table thead th {
    background-color: var(--ctfx-gray-100);
    color: var(--ctfx-gray-800);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--ctfx-gray-300);
    padding: 1rem 0.75rem;
}

.table tbody td {
    padding: 0.875rem 0.75rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: var(--ctfx-gray-50);
}

/* ========================================
   12. Badges & Status Indicators
   ======================================== */
.badge {
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: var(--ctfx-border-radius);
}

.status-accepted {
    background-color: var(--ctfx-success);
    color: var(--ctfx-white);
}

.status-awaiting {
    background-color: var(--ctfx-warning);
    color: var(--ctfx-gray-900);
}

.status-collected {
    background-color: var(--ctfx-info);
    color: var(--ctfx-white);
}

.status-delivered {
    background-color: var(--ctfx-success);
    color: var(--ctfx-white);
}

/* ========================================
   13. Alerts & Toast Messages
   ======================================== */
.alert {
    border: none;
    border-radius: var(--ctfx-border-radius);
    padding: 1rem 1.25rem;
}

.alert-primary {
    background-color: rgba(247, 148, 29, 0.1);
    color: var(--ctfx-primary-hover);
    border-left: 4px solid var(--ctfx-primary);
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #a71d2a;
    border-left: 4px solid var(--ctfx-danger);
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: #1e7e34;
    border-left: 4px solid var(--ctfx-success);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
    border-left: 4px solid var(--ctfx-warning);
}

.alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    color: #0c5460;
    border-left: 4px solid var(--ctfx-info);
}

/* Toast Notifications */
.toast {
    min-width: 300px;
    margin-bottom: 0.5rem;
}

.toast.bg-success {
    background-color: var(--ctfx-success) !important;
}

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

.toast.bg-info {
    background-color: var(--ctfx-info) !important;
}

.toast.bg-warning {
    background-color: var(--ctfx-warning) !important;
    color: var(--ctfx-gray-900) !important;
}

/* ========================================
   14. Footer
   ======================================== */
.footer {
    background-color: var(--ctfx-white);
    margin-top: auto;
}

/* ========================================
   15. Utility Classes
   ======================================== */
.text-primary-orange {
    color: var(--ctfx-primary) !important;
}

.bg-primary-orange {
    background-color: var(--ctfx-primary) !important;
}

.border-primary-orange {
    border-color: var(--ctfx-primary) !important;
}

.shadow-ctfx {
    box-shadow: var(--ctfx-shadow) !important;
}

/* ========================================
   16. Responsive Utilities
   ======================================== */
@media (max-width: 768px) {
    .auth-card {
        margin: 1rem;
    }

    .auth-card-body {
        padding: 1.5rem;
    }
}

/* ========================================
   17. Animation & Transitions
   ======================================== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* ========================================
   18. HTMX Loading States
   ======================================== */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--ctfx-gray-300);
    border-top-color: var(--ctfx-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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