/* Custom CSS for Conciliator Duty Record System */

/* =========================================
   Base Styles & Typography
   ========================================= */
* {
    font-family: 'Sarabun', sans-serif;
    transition: all 0.3s ease;
}

body {
    background: linear-gradient(135deg, #003d7a 0%, #0059b3 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #f8f9fa;
}

/* Thai number formatting */
.thai-number {
    font-family: 'Sarabun', sans-serif;
}

/* Fix text legibility on dark background */
.text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Restore text-muted in light containers */
.card .text-muted,
.navbar .text-muted,
.footer .text-muted,
.dropdown-menu .text-muted,
.modal-content .text-muted,
.bg-light .text-muted,
.bg-white .text-muted {
    color: #6c757d !important;
}

/* Ensure dropdowns and modals have dark text */
.dropdown-menu,
.modal-content {
    color: #333;
}

/* =========================================
   Components: Navbar
   ========================================= */
.navbar {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 61, 122, 0.15);
    border-bottom: 3px solid #d4af37;
    color: #333;
}

.navbar-brand {
    font-weight: 700;
    color: #003d7a !important;
    font-size: 1.3rem;
}

/* =========================================
   Components: Cards
   ========================================= */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.98);
    border-top: 4px solid #d4af37;
    margin-bottom: 1.5rem;
    color: #333;
}

.card-header {
    background: linear-gradient(135deg, #003d7a 0%, #0059b3 100%);
    color: white;
    border-radius: 15px 15px 0 0 !important;
    padding: 1.5rem;
    font-weight: 600;
    font-size: 1.2rem;
    border-bottom: 3px solid #d4af37;
}

.stat-card {
    background: #ffffff;
    color: #333;
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 61, 122, 0.4);
}

.stat-card i {
    font-size: 2.5rem;
    opacity: 0.9;
    color: #d4af37;
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
    color: #003d7a;
}

.stat-card p {
    margin: 0;
    opacity: 0.95;
}

/* =========================================
   Components: Buttons & Forms
   ========================================= */
.btn-primary {
    background: linear-gradient(135deg, #003d7a 0%, #0059b3 100%);
    border: none;
    border-radius: 10px;
    padding: 0.6rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 61, 122, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 61, 122, 0.5);
    background: linear-gradient(135deg, #0059b3 0%, #003d7a 100%);
}

.btn-secondary {
    border-radius: 10px;
    padding: 0.6rem 1.5rem;
    font-weight: 500;
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    padding: 0.7rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #003d7a;
    box-shadow: 0 0 0 0.2rem rgba(0, 61, 122, 0.25);
    outline: none;
    /* Combine outline removal */
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
}

::placeholder {
    color: #999;
    opacity: 1;
}

.input-group-text {
    background-color: #f8f9fa;
    border-color: #e0e0e0;
    color: #003d7a;
}

/* =========================================
   Components: Tables & Others
   ========================================= */
.table {
    border-radius: 10px;
    overflow: hidden;
}

.table thead {
    background: linear-gradient(135deg, #003d7a 0%, #0059b3 100%);
    color: white;
}

.alert {
    border-radius: 10px;
    border: none;
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
}

hr {
    border-color: #d4af37;
    opacity: 0.3;
}

.main-content {
    margin-top: 2rem;
    margin-bottom: 2rem;
    flex: 1;
}

.footer {
    background: rgba(255, 255, 255, 0.98);
    padding: 2rem 0;
    margin-top: auto;
    box-shadow: 0 -2px 20px rgba(0, 61, 122, 0.15);
    border-top: 3px solid #d4af37;
    color: #333;
}

/* =========================================
   Utilities
   ========================================= */
/* Loading spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
    /* Also style horizontal scrollbar */
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* =========================================
   Mobile Responsiveness Upgrades
   ========================================= */

/* Large Tablets and Down (≤ 1199px) */
@media (max-width: 1199.98px) {
    .container {
        max-width: 100%;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Tablets and Down (≤ 991px) */
@media (max-width: 991.98px) {

    /* Navbar */
    .navbar-collapse {
        background: rgba(255, 255, 255, 0.98);
        padding: 1rem;
        border-radius: 0 0 15px 15px;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        margin-top: 0.5rem;
    }

    .navbar-nav {
        padding: 0.5rem 0;
    }

    .nav-item {
        margin: 0.25rem 0;
    }

    /* Dropdown menus in navbar */
    .navbar .dropdown-menu {
        position: static !important;
        transform: none !important;
        border: none;
        box-shadow: none;
        background: rgba(0, 61, 122, 0.05);
        margin-top: 0.5rem;
    }

    /* Cards */
    .card {
        margin-bottom: 1.25rem;
    }
}

/* Small Tablets and Mobile (≤ 767px) */
@media (max-width: 767.98px) {

    /* === Layout === */
    .main-content {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Row and Column Spacing */
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    .row>* {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* === Navigation === */
    .navbar {
        padding: 0.5rem 1rem;
    }

    .navbar-brand img {
        height: 40px !important;
    }

    .navbar-brand div div:first-child {
        font-size: 1rem !important;
    }

    .navbar-brand div div:last-child {
        font-size: 0.65rem !important;
    }

    /* Notification dropdown - make wider on mobile */
    #notificationDropdown+.dropdown-menu {
        min-width: 90vw !important;
        max-width: 90vw;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    /* === Cards === */
    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 1rem;
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* Stat Cards */
    .stat-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .stat-card h3 {
        font-size: 2rem;
    }

    .stat-card i {
        font-size: 2rem;
    }

    .stat-card p {
        font-size: 0.9rem;
    }

    /* === Typography === */
    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    h4 {
        font-size: 1.1rem !important;
    }

    h5 {
        font-size: 1rem !important;
    }

    h6 {
        font-size: 0.9rem !important;
    }

    /* === Tables === */
    .table-responsive {
        border-radius: 10px;
        -webkit-overflow-scrolling: touch;
        /* Smooth scrolling on iOS */
    }

    .table {
        min-width: 600px;
        /* Force horizontal scroll for better data display */
        font-size: 0.9rem;
    }

    .table td,
    .table th {
        white-space: nowrap;
        padding: 0.5rem;
        vertical-align: middle;
    }

    /* Make first column sticky for easier navigation */
    .table td:first-child,
    .table th:first-child {
        position: sticky;
        left: 0;
        background: white;
        z-index: 10;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    }

    .table thead th:first-child {
        background: linear-gradient(135deg, #003d7a 0%, #0059b3 100%);
    }

    /* === Buttons === */
    .btn {
        min-height: 44px;
        /* Apple's recommended touch target */
        font-size: 1rem;
        padding: 0.65rem 1.25rem;
    }

    /* Primary action buttons full width */
    .card-body>.btn,
    .card-body>a.btn,
    .card-body>form>.btn {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    /* Keep button groups compact */
    .btn-group .btn,
    .d-flex .btn,
    .btn-toolbar .btn,
    td .btn {
        width: auto;
        margin-bottom: 0;
        min-height: 36px;
        /* Slightly smaller for groups */
        padding: 0.4rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Full width button modifier */
    .btn-block {
        width: 100%;
        display: block;
    }

    /* === Forms === */
    .form-control,
    .form-select {
        font-size: 16px;
        /* Prevent iOS zoom */
        min-height: 44px;
        padding: 0.65rem 1rem;
    }

    textarea.form-control {
        min-height: 100px;
    }

    /* Form labels */
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }

    /* Input groups */
    .input-group {
        flex-wrap: nowrap;
    }

    .input-group-text {
        font-size: 0.9rem;
    }

    /* Make select dropdowns easier to tap */
    select.form-select {
        background-size: 20px;
    }

    /* === Spacing === */
    .mb-4,
    .my-4 {
        margin-bottom: 1.5rem !important;
    }

    .mt-4,
    .my-4 {
        margin-top: 1.5rem !important;
    }

    .p-4 {
        padding: 1.5rem !important;
    }

    .py-4 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    /* === Badges === */
    .badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    /* === Modals === */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 12px;
    }

    /* === Pagination === */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-item {
        margin: 0.25rem;
    }

    .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    /* === Footer === */
    .footer {
        padding: 1.5rem 0;
        font-size: 0.85rem;
    }

    .footer p {
        margin-bottom: 0.5rem;
    }

    /* === Alerts === */
    .alert {
        font-size: 0.9rem;
        padding: 0.75rem;
    }

    /* === Dashboard Specific === */
    .section-title {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .recent-item {
        padding: 0.75rem !important;
    }

    .request-type-badge {
        font-size: 0.7rem;
    }

    /* === Dropdown Menus === */
    .dropdown-menu {
        font-size: 0.95rem;
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .dropdown-item i {
        margin-right: 0.5rem;
        font-size: 1.1rem;
    }
}

/* Extra Small Mobile (≤ 575px) */
@media (max-width: 575.98px) {

    /* Even more compact for very small screens */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.35rem !important;
    }

    .card-header {
        font-size: 0.95rem;
        padding: 0.85rem;
    }

    .btn {
        font-size: 0.95rem;
        padding: 0.6rem 1rem;
    }

    /* Statistics cards stack on extra small screens */
    .stat-card {
        padding: 1rem;
    }

    .stat-card h3 {
        font-size: 1.75rem;
    }

    .stat-card i {
        font-size: 1.75rem;
    }

    /* Compact table for very small screens */
    .table {
        font-size: 0.85rem;
    }

    .table td,
    .table th {
        padding: 0.4rem;
    }
}

/* Landscape Orientation Fixes */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar-brand img {
        height: 35px !important;
    }

    .main-content {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .card {
        margin-bottom: 0.75rem;
    }
}

/* Print Styles */
@media print {

    .navbar,
    .footer,
    .btn,
    .no-print,
    .dropdown,
    .pagination {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
        page-break-inside: avoid;
    }

    body {
        background: white !important;
    }

    .card-header {
        background: white !important;
        color: black !important;
        border-bottom: 2px solid #000 !important;
    }

    .table {
        border: 1px solid #000;
    }

    .table thead {
        background: #f0f0f0 !important;
        color: black !important;
    }

    /* Ensure tables fit on page */
    .table-responsive {
        overflow: visible !important;
    }

    .table {
        min-width: auto !important;
    }
}