/**
 * Main Stylesheet
 * Custom styles for the SaaS portal
 */

/* CSS Variables */
:root {
    --primary-color: #475569;
    --primary-dark: #334155;
    --primary-light: #64748b;
    --primary-rgb: 71, 85, 105;

    /* Muted stat colors */
    --stat-slate: #64748b;
    --stat-blue: #6b8cae;
    --stat-green: #6b9080;
    --stat-amber: #a8915a;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8fafc;
}

/* Page Layout */
.page-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #1e293b;
}

.page-subtitle {
    color: #64748b;
    margin-bottom: 0;
}

/* Card Improvements */
.card {
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.card-header {
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
}

/* Table Styles */
.table th {
    font-weight: 600;
    background-color: #f8fafc;
    color: #475569;
}

/* Table responsive - horizontal scroll on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Form Styles */
.form-label {
    font-weight: 500;
    color: #374151;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.15);
}

/* Button Styles */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

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

.btn-primary:active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

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

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

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

a:hover {
    color: var(--primary-dark);
}

/* Stat Card Icon Colors - Muted Professional Tones */
.stat-icon-slate {
    background-color: rgba(100, 116, 139, 0.12) !important;
    color: var(--stat-slate) !important;
}

.stat-icon-blue {
    background-color: rgba(107, 140, 174, 0.12) !important;
    color: var(--stat-blue) !important;
}

.stat-icon-green {
    background-color: rgba(107, 144, 128, 0.12) !important;
    color: var(--stat-green) !important;
}

.stat-icon-amber {
    background-color: rgba(168, 145, 90, 0.12) !important;
    color: var(--stat-amber) !important;
}

/* =====================
   Badge System - Muted Professional Colors
   ===================== */

/* Badge Variables */
:root {
    /* Billing Type */
    --badge-tm: #4a6fa5;         /* T&M - muted steel blue */
    --badge-bid: #5a6672;        /* Bid - muted slate */

    /* Ticket/Workflow Status */
    --badge-draft: #6c757d;      /* Draft - muted gray */
    --badge-submitted: #3a5a8c;  /* Submitted - muted navy */
    --badge-approved: #3a7d5c;   /* Approved - muted forest green */
    --badge-rejected: #8c3a3a;   /* Rejected - muted brick red */

    /* Employee Roles */
    --badge-admin: #7d4a4a;      /* Admin - muted burgundy */
    --badge-standard: #4a6fa5;   /* Standard - muted steel blue */
    --badge-field: #5a7d6b;      /* Field Only - muted sage */
    --badge-client: #6b6b7d;     /* Client - muted purple-gray */

    /* Entity Status */
    --badge-active: #3a7d5c;     /* Active - muted forest green */
    --badge-inactive: #6c757d;   /* Inactive - muted gray */
    --badge-terminated: #8c3a3a; /* Terminated - muted brick red */

    /* Billable Categories */
    --badge-materials: #5a7d6b;  /* Materials - muted sage */
    --badge-rental: #7d6b5a;     /* Rental - muted brown */
    --badge-subcontract: #6b5a7d; /* Subcontract - muted purple */
    --badge-other: #6c757d;      /* Other - muted gray */

    /* Misc */
    --badge-weight: #5a6672;     /* Weight badges - muted slate */
    --badge-count: #6c757d;      /* Count badges - muted gray */
    --badge-money-positive: #3a7d5c; /* Revenue - muted green */
    --badge-money-negative: #8c3a3a; /* Cost - muted red */
}

/* Base badge styling */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 4px;
}

/* Billing Type Badges */
.badge-billing-tm,
.billing-badge-time_materials {
    background-color: var(--badge-tm) !important;
    color: white !important;
}

.badge-billing-bid,
.billing-badge-bid {
    background-color: var(--badge-bid) !important;
    color: white !important;
}

/* Ticket/Workflow Status Badges */
.badge-status-draft {
    background-color: var(--badge-draft) !important;
    color: white !important;
}

.badge-status-submitted {
    background-color: var(--badge-submitted) !important;
    color: white !important;
}

.badge-status-approved {
    background-color: var(--badge-approved) !important;
    color: white !important;
}

.badge-status-rejected {
    background-color: var(--badge-rejected) !important;
    color: white !important;
}

/* Employee Role Badges */
.badge-role-admin {
    background-color: var(--badge-admin) !important;
    color: white !important;
}

.badge-role-standard {
    background-color: var(--badge-standard) !important;
    color: white !important;
}

.badge-role-field_only {
    background-color: var(--badge-field) !important;
    color: white !important;
}

.badge-role-client {
    background-color: var(--badge-client) !important;
    color: white !important;
}

/* Entity Status Badges */
.badge-entity-active {
    background-color: var(--badge-active) !important;
    color: white !important;
}

.badge-entity-inactive {
    background-color: var(--badge-inactive) !important;
    color: white !important;
}

.badge-entity-terminated {
    background-color: var(--badge-terminated) !important;
    color: white !important;
}

/* Billable Category Badges */
.badge-category-materials {
    background-color: var(--badge-materials) !important;
    color: white !important;
}

.badge-category-rental {
    background-color: var(--badge-rental) !important;
    color: white !important;
}

.badge-category-subcontract {
    background-color: var(--badge-subcontract) !important;
    color: white !important;
}

.badge-category-other {
    background-color: var(--badge-other) !important;
    color: white !important;
}

/* Misc Badges */
.badge-weight {
    background-color: var(--badge-weight) !important;
    color: white !important;
}

.badge-count {
    background-color: var(--badge-count) !important;
    color: white !important;
}

.badge-money-positive {
    background-color: var(--badge-money-positive) !important;
    color: white !important;
}

.badge-money-negative {
    background-color: var(--badge-money-negative) !important;
    color: white !important;
}

/* Override Bootstrap badge colors with muted versions */
.badge.bg-primary {
    background-color: var(--primary-color) !important;
}

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

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

.badge.bg-warning {
    background-color: #8c7a3a !important; /* muted amber */
    color: white !important;
}

.badge.bg-info {
    background-color: var(--badge-field) !important;
    color: white !important;
}

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

/* Table action buttons — always horizontal */
.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    align-items: center;
}

.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
    body {
        font-size: 14px;
    }

    h1, .h1 {
        font-size: 1.25rem;
    }

    h2, .h2 {
        font-size: 1.125rem;
    }

    h3, .h3 {
        font-size: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .page-subtitle {
        font-size: 0.8125rem;
    }

    /* Page header mobile - stack title and button */
    .page-header-mobile {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .page-header-mobile .btn {
        width: 100%;
    }

    .card {
        border-radius: 6px;
    }

    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }

    .main-content {
        padding: 5px !important;
    }

    /* Tighten spacing between elements */
    .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .g-4 {
        --bs-gutter-y: 0.5rem;
        --bs-gutter-x: 0.5rem;
    }

    .g-3 {
        --bs-gutter-y: 0.5rem;
        --bs-gutter-x: 0.5rem;
    }

    /* Filter cards - compact */
    .filter-card .card-body {
        padding: 0.625rem;
    }

    .filter-card .form-label {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .filter-card .form-select-sm,
    .filter-card .form-control-sm {
        font-size: 0.8125rem;
        padding: 0.25rem 0.5rem;
    }

    .filter-card .btn-sm {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Form controls */
    .form-label {
        font-size: 0.8125rem;
        margin-bottom: 0.25rem;
    }

    .form-select-sm,
    .form-control-sm {
        font-size: 0.8125rem;
    }

    /* Stat cards on mobile */
    .stat-card .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.125rem;
    }

    .stat-card .stat-value {
        font-size: 1.375rem;
    }

    /* Quick links on mobile */
    .quick-links .card-body {
        padding: 15px 10px;
    }

    .quick-links .card-body i {
        font-size: 1.75rem;
        margin-bottom: 8px;
    }

    .quick-links .card-title {
        font-size: 0.8125rem;
    }

    .quick-links .card-text {
        font-size: 0.75rem;
    }

    /* Tables on mobile */
    .table {
        font-size: 0.8125rem;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
    }

    /* DataTables mobile */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        font-size: 0.75rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        font-size: 0.8125rem;
    }

    /* Buttons mobile — 44px min touch target (Apple HIG) */
    .btn {
        font-size: 0.8125rem;
        min-height: 44px;
    }

    /* Table action buttons stay compact */
    .action-buttons .btn,
    .dt-actions .btn,
    td .btn,
    th .btn {
        min-height: 36px;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
}

@media (max-width: 767.98px) {
    .toast-container {
        top: 60px;
        right: 10px;
        left: 10px;
    }
}

/* Text colors using primary */
.text-primary {
    color: var(--primary-color) !important;
}

/* Focus ring customization */
.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* DataTables styling adjustments */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
    color: white !important;
}
