/* Admin Dashboard Styles */

/* Override container max-width for admin dashboard on larger screens */
body .container {
    width: min(100%, 1500px);
    max-width: 100%;
    margin: 0 auto;
    padding: clamp(16px, 2.5vw, 30px);
}

@media (min-width: 1200px) {
    body .container {
        max-width: 95%;
        margin: 20px auto;
    }
}

@media (min-width: 1400px) {
    body .container {
        max-width: 98%;
        margin: 20px auto;
    }
}

.dashboard {
    margin-top: 20px;
    width: 100%;
}

.dashboard-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.nav-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
}

.nav-tab:hover {
    color: #0066cc;
}

.nav-tab.active {
    color: #0066cc;
    border-bottom-color: #0066cc;
    font-weight: bold;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Submissions */
.submissions-header {
    margin-bottom: 20px;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
    align-items: center;
}

.filters input,
.filters select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-height: 44px;
}

.filters input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.filters input[type="date"] {
    width: 150px;
}

.filters .btn,
.header-actions .btn,
.nav-tab,
.time-range-btn,
.pagination .btn {
    min-height: 44px;
}

.data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    table-layout: auto;
}

@media (min-width: 1200px) {
    .data-table {
        table-layout: fixed;
    }
    
    .data-table th,
    .data-table td {
        padding: 12px 15px;
    }
    
    /* Checkbox column */
    .data-table th:nth-child(1),
    .data-table td:nth-child(1) {
        width: 3%;
        min-width: 40px;
    }
    
    /* Date column */
    .data-table th:nth-child(2),
    .data-table td:nth-child(2) {
        width: 12%;
    }
    
    /* Tracking Number column */
    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        width: 15%;
    }
    
    /* Equipment Type column */
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        width: 10%;
    }
    
    /* Service column */
    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        width: 10%;
    }
    
    /* Shipper column */
    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        width: 12%;
    }
    
    /* Email column */
    .data-table th:nth-child(7),
    .data-table td:nth-child(7) {
        width: 15%;
    }
    
    /* Weight column */
    .data-table th:nth-child(8),
    .data-table td:nth-child(8) {
        width: 8%;
    }
    
    /* Actions column */
    .data-table th:nth-child(9),
    .data-table td:nth-child(9) {
        width: 8%;
    }
}

.data-table th {
    background: #0066cc;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
    line-height: 1.45;
}

.data-table th,
.data-table td {
    white-space: normal;
}

.data-table td:nth-child(2),
.data-table td:nth-child(3),
.data-table td:nth-child(6),
.data-table td:nth-child(7),
#submissions-content .data-table td:nth-child(1),
#submissions-content .data-table td:nth-child(2),
#submissions-content .data-table td:nth-child(6) {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.data-table td:nth-child(8) {
    white-space: normal;
    min-width: 0;
}

/* Prior submissions table (8 columns, no checkbox) - override column widths */
#submissions-content .data-table th:nth-child(1),
#submissions-content .data-table td:nth-child(1) {
    width: 13%;
}

#submissions-content .data-table th:nth-child(2),
#submissions-content .data-table td:nth-child(2) {
    /* Tracking Number */
    width: 14%;
}

#submissions-content .data-table th:nth-child(3),
#submissions-content .data-table td:nth-child(3) {
    /* Equipment Type */
    width: 11%;
}

#submissions-content .data-table th:nth-child(4),
#submissions-content .data-table td:nth-child(4) {
    /* Service */
    width: 11%;
}

#submissions-content .data-table th:nth-child(5),
#submissions-content .data-table td:nth-child(5) {
    /* Shipper */
    width: 11%;
}

#submissions-content .data-table th:nth-child(6),
#submissions-content .data-table td:nth-child(6) {
    /* Email */
    width: 16%;
}

#submissions-content .data-table th:nth-child(7),
#submissions-content .data-table td:nth-child(7) {
    /* Weight */
    width: 7%;
}

#submissions-content .data-table th:nth-child(8),
#submissions-content .data-table td:nth-child(8) {
    /* Actions */
    width: auto;
    min-width: 140px;
    overflow: visible;
}

#submissions-content .data-table .download-label-btn {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.data-table tr:hover {
    background: #f5f5f5;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    margin-right: 5px;
    min-height: 44px;
    white-space: nowrap;
}

/* Action Menu Dropdown */
.action-menu-container {
    position: relative;
    display: inline-block;
}

.action-menu-btn {
    padding: 8px 12px;
    font-size: 18px;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.action-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 150px;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

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

.action-menu-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.action-menu-item:last-child {
    border-bottom: none;
}

.action-menu-item:hover {
    background-color: #f5f5f5;
}

.action-menu-item.delete-submission-btn {
    color: #dc3545;
}

.action-menu-item.delete-submission-btn:hover {
    background-color: #fee;
    color: #c82333;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination-info {
    color: #666;
}

/* Statistics */
.statistics-header {
    margin-bottom: 20px;
}

.statistics-content {
    width: 100%;
    overflow-x: visible;
}

.time-range-selector {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.time-range-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    flex: 1;
    min-width: 80px;
}

.time-range-btn:hover {
    background: #e0e0e0;
}

.time-range-btn.active {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    width: 100%;
}

@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    min-width: 0; /* Prevent overflow */
    overflow: hidden;
}

.stat-card h3 {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
    font-weight: normal;
    word-wrap: break-word;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #0066cc;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
}

@media (min-width: 1200px) {
    .stats-charts {
        grid-template-columns: repeat(3, 1fr);
    }
}

.chart-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 0; /* Prevent overflow */
    overflow: hidden;
}

.chart-container h3 {
    margin-top: 0;
    color: #0066cc;
    word-wrap: break-word;
}

.chart {
    margin-top: 15px;
    overflow-x: auto;
    width: 100%;
}

.top-shippers {
    overflow-x: auto;
    width: 100%;
}

.top-shippers p {
    margin: 8px 0;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Settings */
.settings-header {
    margin-bottom: 20px;
}

.setting-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.setting-section h3 {
    margin-top: 0;
    color: #0066cc;
}

.setting-section small {
    display: block;
    color: #666;
    margin-top: 5px;
    font-size: 12px;
}

.status-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #ddd;
    background: #0066cc;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.detail-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

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

.detail-section h3 {
    margin-top: 0;
    color: #0066cc;
    font-size: 18px;
}

.detail-section p {
    margin: 8px 0;
    color: #333;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Email Preview Modal */
#email-preview-modal .modal-content {
    max-width: 900px;
}

#email-preview-content {
    padding: 0 !important;
    background: #f5f5f5;
}

#email-preview-content iframe {
    width: 100%;
    border: none;
    min-height: 600px;
}

#email-preview-content .container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: white;
}

/* Loading Screen */
.loading-screen {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    z-index: 9999;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Access Denied */
.access-denied {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.access-denied h2 {
    color: #dc3545;
    margin-bottom: 15px;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Bulk Actions */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
}

.selected-count {
    font-weight: 600;
    color: #0066cc;
    font-size: 14px;
}

#bulk-delete-btn {
    padding: 8px 16px;
    font-size: 14px;
    min-height: 44px;
}

/* Table Container - Prevent Overflow */
#submissions-table-container {
    position: relative;
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid rgba(63, 105, 184, 0.16);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(63, 105, 184, 0.08);
}

/* Override for table container */
#submissions-table-container .data-table {
    margin-top: 0;
    box-shadow: none;
}

#submissions-table-container[data-scrollable="true"] {
    padding-bottom: 28px;
}

#submissions-table-container[data-scrollable="true"]::before {
    content: "Scroll to see more columns";
    position: absolute;
    right: 12px;
    bottom: 6px;
    z-index: 2;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(63, 105, 184, 0.12);
    color: #34589d;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
}

#submissions-table-container[data-scrollable="true"]::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 56px;
    height: calc(100% - 28px);
    background: linear-gradient(270deg, rgba(255,255,255,0.96) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}

#submissions-table-container[data-scrolled-end="true"]::before,
#submissions-table-container[data-scrolled-end="true"]::after,
#submissions-table-container[data-scrollable="false"]::before,
#submissions-table-container[data-scrollable="false"]::after {
    opacity: 0;
}

@media (min-width: 768px) {
    .data-table {
        width: 100%;
        table-layout: fixed;
    }
}

/* Ensure all tab content uses full width */
.tab-content {
    width: 100%;
}

.tab-content.active {
    width: 100%;
}

/* Submissions tab full width */
#submissions-tab {
    width: 100%;
}

/* Statistics tab full width */
#statistics-tab {
    width: 100%;
}

.statistics-content {
    width: 100%;
    max-width: 100%;
}

/* Settings tab full width */
#settings-tab {
    width: 100%;
}

.settings-content {
    width: 100%;
    max-width: 100%;
}

/* Header Actions - Prevent Overlap */
.header-actions {
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

header {
    position: static;
    background: var(--white);
    padding-top: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-gray);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

header h1 {
    margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 1200px) {
    .data-table {
        font-size: 13px;
        table-layout: auto;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 8px;
    }

    #submissions-content .data-table th,
    #submissions-content .data-table td {
        width: auto;
        min-width: 0;
    }
}

@media (max-width: 992px) {
    .filters {
        flex-wrap: wrap;
    }
    
    .filters input[type="text"] {
        min-width: 100%;
    }
    
    .filters input[type="date"] {
        flex: 1;
        min-width: 140px;
    }
    
    .filters select {
        flex: 1;
        min-width: 150px;
    }

    body .container {
        padding: 18px;
    }
    
    .stats-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        padding-bottom: 15px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .header-actions {
        width: 100%;
        margin-top: 15px;
    }
    
    .header-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .dashboard-nav {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .nav-tab {
        padding: 8px 12px;
        font-size: 14px;
        flex: 1;
        min-width: 100px;
    }
    
    .filters {
        flex-direction: column;
        gap: 8px;
    }
    
    .filters input,
    .filters select {
        width: 100%;
        min-width: 100%;
    }
    
    .filters input[type="date"] {
        width: 100%;
    }
    
    .filters .btn {
        width: 100%;
        margin-top: 5px;
    }
    
    #submissions-table-container {
        border-radius: 14px;
    }
    
    .data-table {
        font-size: 14px;
    }

    .data-table th,
    .data-table td,
    .btn-small {
        font-size: 14px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }
    
    .statistics-header {
        margin-bottom: 15px;
    }
    
    .statistics-header h2 {
        font-size: 1.3em;
    }
    
    .time-range-selector {
        flex-wrap: wrap;
        gap: 5px;
        margin-top: 10px;
    }
    
    .time-range-btn {
        flex: 1;
        min-width: 70px;
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-card h3 {
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stats-charts {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chart-container {
        padding: 15px;
    }
    
    .chart-container h3 {
        font-size: 16px;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        flex-direction: column;
        padding: 15px;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
        margin: 0 auto;
    }
    
    header h1 {
        font-size: 1.2em;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
    
    .btn-small {
        padding: 8px 10px;
        font-size: 14px;
        margin: 2px;
    }
    
    .action-menu-btn {
        padding: 8px 10px;
        font-size: 16px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .action-menu-dropdown {
        min-width: 130px;
    }
    
    .action-menu-item {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .statistics-header h2 {
        font-size: 1.1em;
    }
    
    .time-range-selector {
        gap: 4px;
    }
    
    .time-range-btn {
        min-width: 60px;
        padding: 5px 8px;
        font-size: 11px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .stat-card h3 {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stats-charts {
        gap: 10px;
    }
    
    .chart-container {
        padding: 12px;
    }
    
    .chart-container h3 {
        font-size: 14px;
    }
    
    .top-shippers p {
        font-size: 12px;
        padding: 6px;
    }

    #submissions-table-container[data-scrollable="true"]::before {
        right: 8px;
        bottom: 8px;
        font-size: 14px;
    }
}

@media (max-width: 430px) {
    body .container {
        padding: 12px;
    }

    .filters input,
    .filters select,
    .filters .btn {
        font-size: 14px;
    }

    .data-table th,
    .data-table td {
        min-width: 110px;
    }

    .data-table th:first-child,
    .data-table td:first-child {
        min-width: 84px;
    }

    .data-table th:last-child,
    .data-table td:last-child {
        min-width: 92px;
    }
}

@media (max-width: 375px) {
    body .container {
        padding: 10px;
    }

    #submissions-table-container {
        border-radius: 12px;
    }
}

@media (max-width: 320px) {
    body .container {
        padding: 8px;
    }

    .data-table {
        font-size: 11px;
    }
}

