:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4cc9f0;
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --border-radius: 12px;
    --box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    --transition: all 0.3s ease;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--dark-text);
}

.navbar {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

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

.btn-primary {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 50px;
    padding: 10px 25px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
}

.header-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}

.document-card {
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.document-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-valid { background-color: #d4edda; color: #155724; }
.status-invalid { background-color: #f8d7da; color: #721c24; }
.status-cancelled { background-color: #fff3cd; color: #856404; }
.status-submitted { background-color: #cce5ff; color: #004085; }

.document-type {
    background-color: #e7f1ff;
    color: var(--secondary-color);
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    line-height: 1.2;
    white-space: nowrap;
}

.filter-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}

.stats-card {
    text-align: center;
    padding: 20px;
}

.stats-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 10px 0;
}

.stats-label {
    color: #6c757d;
    font-size: 0.9rem;
}

.loading-spinner {
    display: none;
    text-align: center;
    padding: 30px;
}

.loading-spinner.show {
    display: block;
}

.pagination {
    justify-content: center;
}

.footer {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    margin-top: 30px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

.search-box input {
    padding-left: 40px;
}

.document-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Animation for refresh icon */
.rotating {
    animation: rotate 1s linear infinite;
}

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

/* Modern Document Table */
#documentsTable {
    border-collapse: separate;
    border-spacing: 0 12px;
    background: transparent;
}
#documentsTable thead th {
    border: none;
    padding: 0 15px 10px 15px;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}
#documentsTable tbody tr {
    background-color: white;
    transition: var(--transition);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    border-radius: var(--border-radius);
}
#documentsTable tbody tr:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(67, 97, 238, 0.12) !important;
    background-color: white !important;
}
#documentsTable tbody td {
    padding: 18px 15px;
    border: none;
    vertical-align: middle;
    background-color: white;
}
#documentsTable tbody td:first-child {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}
#documentsTable tbody td:last-child {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

/* Remove default bootstrap hover shadow */
.table-hover>tbody>tr:hover>* {
    --bs-table-accent-bg: transparent !important;
    color: inherit !important;
}

/* Mobile Responsive Table */
@media screen and (max-width: 767px) {
    #documentsTable {
        border-spacing: 0;
    }
    #documentsTable thead {
        display: none;
    }
    #documentsTable tr {
        display: block;
        margin-bottom: 1.5rem !important;
        border: 1px solid #eee;
        padding: 15px;
    }
    #documentsTable td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0 !important;
        border-bottom: 1px solid #f8f9fa !important;
        border-radius: 0 !important;
    }
    #documentsTable td:last-child {
        border-bottom: none !important;
        padding-top: 15px !important;
    }
    #documentsTable td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        font-size: 0.8rem;
        color: #6c757d;
        text-transform: uppercase;
    }

    /* Special handling for supplier and buyer fields */
    #documentsTable td[data-label="Supplier"],
    #documentsTable td[data-label="Customer"],
    #documentsTable td[data-label="Buyer"] {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
    }
    #documentsTable td[data-label="Supplier"]::before,
    #documentsTable td[data-label="Customer"]::before,
    #documentsTable td[data-label="Buyer"]::before {
        white-space: nowrap;
        margin-right: 10px;
    }
    #documentsTable .supplier-value,
    #documentsTable .buyer-value {
        text-align: right;
        flex: 1;
        word-break: break-word;
    }
}

/* Detail Page Styles */
.document-header {
    margin-bottom: 25px;
}

.detail-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.detail-title {
    color: var(--primary-color);
    margin: 0 0 15px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    align-items: center;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f8f9fa;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 500;
}

.detail-value {
    color: var(--dark-text);
    font-size: 0.95rem;
    text-align: right;
    word-break: break-word;
    max-width: 70%;
}

.line-items-table {
    width: 100%;
    border-collapse: collapse;
}

.line-items-table th {
    background-color: #f8f9fa;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.line-items-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.line-items-table tr:last-child td {
    border-bottom: none;
}

.line-items-table tr:hover {
    background-color: #f8f9fa;
}

.actions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.status-submitted { background-color: #cce5ff; color: #004085; }
.status-valid { background-color: #d4edda; color: #155724; }
.status-invalid { background-color: #f8d7da; color: #721c24; }
.status-cancelled { background-color: #fff3cd; color: #856404; }
.status-pending { background-color: #fff3cd; color: #856404; }
.status-processing { background-color: #cce5ff; color: #004085; }

/* Responsive Button Group for mobile */
@media (max-width: 767.98px) {
    .btn-group-responsive {
        flex-wrap: wrap !important;
    }
    .btn-group-responsive > .btn {
        flex: 1 0 25% !important;
        border-radius: 0 !important;
        margin-left: -1px !important;
        margin-top: -1px !important;
    }
    /* Rounded corners for the grid layout */
    .btn-group-responsive > .btn:nth-child(1) {
        border-top-left-radius: 8px !important;
    }
    .btn-group-responsive > .btn:nth-child(4) {
        border-top-right-radius: 8px !important;
    }
    .btn-group-responsive > .btn:nth-child(5) {
        border-bottom-left-radius: 8px !important;
    }
    .btn-group-responsive > .btn:last-child {
        border-bottom-right-radius: 8px !important;
    }
}