/**
 * Social-X Admin Panel - Centralized Styles
 * Includes all common admin styles to prevent FOUC and code duplication
 */

/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #3b82f6;
    --bg-light: #f8fafc;
    --border: #e2e8f0;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

/* ===== Core Layout ===== */
.dashboard-body {
    background: var(--bg-light);
    min-height: 100vh;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 24px;
    margin-right: 280px;
    transition: margin-right 0.3s ease;
}

.content-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

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

/* ===== Stats Cards ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.green {
    background: #d1fae5;
    color: var(--success);
}

.stat-icon.orange {
    background: #fef3c7;
    color: var(--warning);
}

.stat-icon.red {
    background: #fee2e2;
    color: var(--danger);
}

.stat-icon.purple {
    background: #ede9fe;
    color: #7c3aed;
}

.stat-info h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-info p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Tables ===== */
.table-wrapper {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 800px;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 700;
    color: #374151;
    font-size: 13px;
}

.data-table th .col-label {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: var(--primary);
}

.data-table th small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.data-table td {
    font-size: 14px;
}

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

/* ===== Status Badges ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-pending::before {
    background: #f59e0b;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-completed::before {
    background: #10b981;
}

.status-processing {
    background: #dbeafe;
    color: #1e40af;
}

.status-processing::before {
    background: #3b82f6;
}

.status-cancelled {
    background: #fee2e2;
    color: #dc2626;
}

.status-cancelled::before {
    background: #ef4444;
}

/* Role badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #047857;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
}

.form-control small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== Order-Specific Styles ===== */
.link-cell {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
}

.provider-id {
    font-size: 11px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #64748b;
    display: inline-block;
    margin-top: 4px;
}

/* Mobile Order Cards */
.mobile-orders-container {
    display: none;
    flex-direction: column;
    gap: 15px;
}

.order-card {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.order-card-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-card-id {
    font-size: 18px;
    font-weight: 800;
}

.order-card-id small {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 400;
}

.order-card-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}

.order-card-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.order-card-status.inprogress {
    background: #dbeafe;
    color: #1e40af;
}

.order-card-status.processing {
    background: #e0e7ff;
    color: #3730a3;
}

.order-card-status.completed {
    background: #dcfce7;
    color: #166534;
}

.order-card-status.partial {
    background: #f3f4f6;
    color: #374151;
}

.order-card-status.canceled {
    background: #fee2e2;
    color: #991b1b;
}

.order-card-status.refunded {
    background: #fee2e2;
    color: #991b1b;
}

.order-card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
}

.order-info-row:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.order-info-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.order-info-value {
    font-size: 13px;
    color: #1e293b;
    font-weight: 700;
    text-align: left;
}

.order-service-name {
    font-size: 14px;
    font-weight: 800;
    color: #2563eb;
    margin-bottom: 5px;
}

.order-service-ids {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.service-id-badge {
    font-size: 10px;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    color: #475569;
    font-family: monospace;
}

.order-link-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.order-link-text {
    flex: 1;
    font-size: 11px;
    color: #64748b;
    direction: ltr;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-link-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.copy-link-btn:active {
    transform: scale(0.95);
}

.order-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.price-box {
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.price-box.local {
    border-right: 3px solid #2563eb;
}

.price-box.provider {
    border-right: 3px solid #10b981;
}

.price-label {
    font-size: 10px;
    color: #64748b;
    margin-bottom: 4px;
}

.price-value {
    font-size: 14px;
    font-weight: 800;
}

/* ===== Animations ===== */
@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h4 {
    margin: 0 0 8px;
    color: var(--text-dark);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

.pagination a {
    background: white;
    color: var(--primary);
    border: 1px solid var(--border);
    text-decoration: none;
}

.pagination a:hover {
    background: var(--primary-light);
}

.pagination .current {
    background: var(--primary);
    color: white;
}

/* ===== Filters ===== */
.filters-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: end;
}

.filters-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

/* ===== Responsive - Mobile (< 992px) ===== */
@media (max-width: 992px) {
    .main-content {
        margin-right: 0;
        padding: 16px;
    }

    .content-card {
        padding: 16px;
        border-radius: var(--radius);
    }

    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .card-header h2 {
        font-size: 1.1rem;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .stat-info h3 {
        font-size: 18px;
    }

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

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 8px 10px;
        font-size: 11px;
    }

    .btn-group .btn {
        flex: 1;
        min-width: 40px;
    }

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

    .filters-form .form-group {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
}

/* ===== Responsive - Small Mobile (< 480px) ===== */
@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: row;
    }
}