/* ===================================
   Order Dashboard - Stylesheet
   =================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --dark: #0f172a;
    --light: #f8fafc;
    --border: #e2e8f0;
    --hover: #f1f5f9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    color: var(--dark);
    padding: 2rem;
}

/* Credential Modal Reset */
#credentialPrompt {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
}

#credentialPrompt .credential-overlay,
#credentialPrompt .credential-modal {
    position: static !important;
    margin: auto !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    margin-bottom: 2rem;
}

h1 {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1 i {
    color: var(--primary);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card i {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
}

.stat-card .label {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0.5rem;
}

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.refresh-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-btn:hover {
    background: var(--primary-dark);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--light);
    border-bottom: 1px solid var(--border);
}

.table-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.table-info span {
    color: #64748b;
    font-size: 0.875rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--light);
}

th {
    padding: 0.5rem;
    font-weight: 600;
    color: var(--dark);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--light);
    z-index: 10;
    min-width: 130px;
    vertical-align: top;
    white-space: nowrap;
    display: table-cell;
}

th .th-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}

th .th-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    margin-right: 0.35rem;
    flex-shrink: 0;
}

.column-filter {
    width: 90px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: white;
}

.column-filter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.column-filter::placeholder {
    color: #94a3b8;
}

th.filter-active .column-filter {
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.05);
}

.th-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

th .sort-indicator {
    display: inline-flex;
    flex-direction: column;
    margin-left: 0.5rem;
    cursor: pointer;
    opacity: 0.3;
}

th .sort-indicator:hover {
    opacity: 1;
}

th .sort-indicator i {
    font-size: 0.75rem;
    line-height: 1;
}

th .sort-indicator.active {
    opacity: 1;
}

th .sort-indicator.active i:first-child {
    color: var(--primary);
}

th .sort-indicator.active i:last-child {
    color: #cbd5e1;
}

th .filter-indicator {
    display: inline-flex;
    margin-left: 0.5rem;
    cursor: pointer;
    color: var(--primary);
}

th .filter-indicator i {
    font-size: 0.875rem;
    opacity: 0.3;
}

th .filter-indicator.active i {
    opacity: 1;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: #475569;
}

tr:hover {
    background: var(--hover);
}

.cell-country {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.country-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.country-badge.finland {
    background: #003580;
}

.country-badge.spanien {
    background: #aa151b;
}

.country-badge.deutschland {
    background: #000000;
}

.country-badge.unknown {
    background: #94a3b8;
}

.country-badge.b2b {
    background: #00008b;
}

.cell-vat {
    font-family: monospace;
    font-size: 0.85rem;
}

.cell-vat.empty {
    color: #94a3b8;
    font-style: italic;
}

.cell-remark {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.cell-remark.warning {
    color: var(--warning);
}

.cell-remark.success {
    color: var(--success);
}

.cell-remark.danger {
    color: var(--danger);
}

.cell-remark.remark-nok {
    color: var(--danger);
    font-weight: 600;
}

.cell-remark.remark-danger {
    color: var(--danger);
}

.cell-remark.remark-success {
    color: var(--success);
}

.recheck-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary);
    border: 2px solid var(--border);
    border-radius: 4px;
}

.recheck-checkbox:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.recheck-checkbox:hover {
    border-color: var(--primary);
}

/* Filter Dropdown */
.filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    z-index: 100;
    min-width: 200px;
    margin-top: 0.5rem;
    padding: 0.5rem;
    display: none;
}

.filter-dropdown.show {
    display: block;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.filter-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark);
}

.filter-header .close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: #64748b;
}

.filter-list {
    max-height: 200px;
    overflow-y: auto;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.filter-item:hover {
    background: var(--hover);
    border-radius: 4px;
}

.filter-item input {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.filter-item label {
    flex: 1;
    font-size: 0.875rem;
    color: var(--dark);
}

.filter-clear {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--hover);
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: #64748b;
}

.filter-clear:hover {
    background: #e2e8f0;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--primary);
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-right: 1rem;
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #64748b;
}

.empty-state i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1rem;
}

/* Credential Modal Styles */
.credential-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    width: 100vw;
    height: 100vh;
}

.credential-modal {
    position: static;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    width: 90%;
    max-width: 450px;
    padding: 2rem;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 9999;
    transform: none;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.credential-content {
    text-align: center;
}

.credential-header {
    margin-bottom: 1.5rem;
}

.credential-header i {
    color: var(--primary);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.credential-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

.credential-modal p {
    color: #64748b;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.input-group {
    position: relative;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.btn-primary {
    flex: 1;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--hover);
    color: #64748b;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.credential-help {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--hover);
    border-radius: 8px;
    font-size: 0.875rem;
    color: #64748b;
}

.credential-help i {
    color: var(--primary);
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    .controls {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    th, td {
        padding: 0.75rem 1rem;
    }

    .credential-modal {
        padding: 1.5rem;
        margin: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
    }
}
