/* Admin page - Matching main site branding */

.admin-body {
    --brand-yellow: #FCD34D;
    --brand-orange: #F59E0B;
    --brand-orange-dark: #D97706;
    --brand-red: #DC2626;
    --brand-ink: #111827;
    --brand-ink-soft: #1F2937;

    --primary: var(--brand-orange);
    --primary-dark: var(--brand-orange-dark);
    --secondary: #FBBF24;
    --accent: var(--brand-red);
    --dark: var(--brand-ink);
    --gray: #475569;
    --light-gray: #E2E8F0;
    --bg-light: #FFF7E6;
    --white: #FFFFFF;
    --surface: #FFFFFF;
    --surface-muted: #FFF3D6;
    --border: rgba(17, 24, 39, 0.08);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --shadow-sm: 0 2px 10px rgba(17, 24, 39, 0.08);
    --shadow-md: 0 12px 28px rgba(17, 24, 39, 0.12);
    --shadow-lg: 0 24px 60px rgba(17, 24, 39, 0.18);
    --shadow-xl: 0 30px 80px rgba(17, 24, 39, 0.22);
    --shadow-glow: 0 0 24px rgba(245, 158, 11, 0.35);

    --radius: 12px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --gradient-brand: linear-gradient(135deg, var(--primary), var(--secondary));
    --focus-outline: 2px solid rgba(245, 158, 11, 0.7);
    --focus-ring: 0 0 0 3px rgba(245, 158, 11, 0.22);

    background: linear-gradient(135deg, #FFF7E6 0%, #FFF3D6 50%, #FFE8CC 100%);
    color: var(--dark);
    min-height: 100vh;
}

.admin-nav {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 2px 10px rgba(17, 24, 39, 0.08);
}

.admin-nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #475569;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.back-link:hover {
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.12);
}

.admin-main {
    min-height: 100vh;
    padding: 32px 0 60px;
}

.admin-main .container {
    max-width: 1440px;
    width: 95%;
}

.admin-card {
    max-width: 520px;
    margin: 0 auto;
    background: #FFFFFF;
    padding: 28px;
    border-radius: 20px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
}

.admin-app .admin-card {
    max-width: none;
    margin: 0;
}

.admin-muted {
    color: #475569;
}

.admin-error {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #b91c1c;
    font-weight: 600;
}

.admin-app {
    margin-top: 10px;
}

.admin-shell {
    display: block;
}

.admin-subnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #FFFFFF;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 20px;
    padding: 12px 24px;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    margin-bottom: 24px;
    gap: 12px;
}

.admin-side-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #111827;
}

#adminSub {
    display: block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #475569;
    font-size: 0.85rem;
}

.admin-side-brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-menu {
    display: flex;
    gap: 10px;
}

.admin-menu.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
}

.admin-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: #475569;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.admin-menu-btn:hover {
    background: rgba(245, 158, 11, 0.12);
    color: #F59E0B;
}

.admin-menu-btn.active {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

.admin-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

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

.admin-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.kpi-card {
    background: #FFFFFF;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 20px;
    padding: 18px 20px;
    box-shadow: 0 2px 10px rgba(17, 24, 39, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
}

.kpi-label {
    font-size: 0.8rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 6px;
    color: #F59E0B;
    font-family: 'Outfit', sans-serif;
}

.admin-bulk {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(18, 23, 38, 0.75);
    margin-bottom: 16px;
}

.bulk-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    align-items: start;
}

.admin-detail {
    position: sticky;
    top: 20px;
}

.detail-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 3000;
}

.detail-modal.open {
    display: flex;
}

.detail-modal-card {
    background: #ffffff;
    width: min(94vw, 640px);
    max-height: 90vh;
    overflow: auto;
    border-radius: 20px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    padding: 16px;
}

.detail-modal-header {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.admin-table-wrap {
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    border: 1px solid rgba(17, 24, 39, 0.08);
    overflow-x: auto;
}

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

.admin-table thead {
    background: #FFF3D6;
}

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    font-size: 0.9rem;
}

.admin-table th:first-child,
.admin-table td:first-child {
    width: 40px;
    padding-left: 18px;
}

.admin-table input[type="checkbox"] {
    accent-color: #F59E0B;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.admin-table th {
    text-align: left;
    color: #475569;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-row {
    cursor: pointer;
    transition: background 0.2s ease;
}

.admin-row:hover {
    background: rgba(245, 158, 11, 0.08);
}

.admin-row.selected {
    background: rgba(245, 158, 11, 0.15);
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.75rem;
    border: 1px solid;
    background: transparent;
}

.pill.new {
    border-color: #3B82F6;
    color: #3B82F6;
}

.pill.confirmed {
    border-color: #10B981;
    color: #10B981;
}

.pill.in_progress {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.pill.sent_preview {
    border-color: #F59E0B;
    color: #F59E0B;
}

.pill.approved {
    border-color: #10B981;
    color: #10B981;
}

.pill.shipped {
    border-color: #06B6D4;
    color: #06B6D4;
}

.pill.completed {
    border-color: #059669;
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
}

.pill.cancelled {
    border-color: #EF4444;
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

.detail-card {
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    padding: 20px;
    border: 1px solid rgba(17, 24, 39, 0.08);
}

.detail-kv {
    margin: 14px 0 0;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px 12px;
    font-size: 0.9rem;
}


.detail-kv .k {
    color: #475569;
    font-weight: 600;
}

.detail-kv .v {
    color: #111827;
    word-break: break-word;
    overflow-wrap: break-word;
}

.thumbs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.thumbs a {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(17, 24, 39, 0.08);
    transition: transform 0.2s ease;
}

.thumbs a:hover {
    transform: scale(1.02);
}

.thumbs img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

/* Uploads section (hidden upload page) */
.uploads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.upload-card {
    background: #FFFFFF;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
    display: grid;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.upload-stack {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-stack img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 10px 20px rgba(17, 24, 39, 0.18);
    background: #f8fafc;
}

.upload-stack.stack-1 img {
    position: relative;
    transform: none;
    box-shadow: var(--shadow-sm);
}

.upload-stack.stack-2 img:nth-child(1) {
    transform: translate(8px, -8px) rotate(-2deg);
    opacity: 0.75;
}

.upload-stack.stack-2 img:nth-child(2) {
    transform: translate(0, 0) rotate(0deg);
}

.upload-stack.stack-3 img:nth-child(1) {
    transform: translate(12px, -10px) rotate(-3deg);
    opacity: 0.6;
}

.upload-stack.stack-3 img:nth-child(2) {
    transform: translate(6px, -6px) rotate(-1.5deg);
    opacity: 0.82;
}

.upload-stack.stack-3 img:nth-child(3) {
    transform: translate(0, 0) rotate(0deg);
}

.upload-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #F59E0B;
    font-weight: 700;
}

.upload-count {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.85);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.75rem;
    z-index: 5;
}

.upload-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.upload-card-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.upload-card-actions .btn {
    justify-content: center;
    width: 100%;
}

.upload-card-title {
    font-weight: 700;
    color: #111827;
}

.upload-card-subtitle {
    color: #475569;
    font-size: 0.85rem;
}

.upload-modal-card {
    width: min(94vw, 920px);
}

.upload-modal-card .detail-modal-header {
    justify-content: space-between;
    align-items: center;
}

.upload-modal-title {
    font-weight: 700;
    color: #111827;
}

.upload-modal-meta {
    margin-bottom: 12px;
    font-weight: 600;
    color: #475569;
}

.upload-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.upload-modal-grid a {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: var(--shadow-sm);
}

.upload-modal-grid img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.detail-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 14px;
}

.admin-media-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 18px;
}

.media-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.asset-list {
    display: grid;
    gap: 12px;
}

.asset-item {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.asset-thumb {
    width: 80px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
}

.asset-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: rgba(230, 233, 245, 0.8);
}

.file-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px dashed rgba(245, 158, 11, 0.4);
    color: #111827;
    background: #FFF3D6;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.file-input:hover {
    border-color: #F59E0B;
}

.file-input::file-selector-button {
    background: linear-gradient(135deg, #F59E0B, #FBBF24);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    margin-right: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.file-input::file-selector-button:hover {
    transform: translateY(-1px);
}

.select-input,
.text-input,
.text-area,
.text-area-small {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    background: #FFFFFF;
    border: 1px solid rgba(17, 24, 39, 0.08);
    color: #111827;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23111827'%3E%3Cpath d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 38px;
    cursor: pointer;
}

.select-input option,
.select-input optgroup {
    color: #111827;
    background: #ffffff;
}

.text-input::placeholder,
.text-area::placeholder,
.text-area-small::placeholder {
    color: #475569;
}

.select-input:focus,
.text-input:focus,
.text-area:focus {
    outline: none;
    border-color: #F59E0B;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.label {
    display: block;
    color: #111827;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.btn {
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #F59E0B;
    color: #fff;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover {
    background: #D97706;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 2px solid #F59E0B;
    color: #F59E0B;
}

.btn-outline:hover {
    background: #F59E0B;
    color: #fff;
}

.btn-danger {
    background: #EF4444;
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.28);
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.affiliate-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-side-brand .nav-logo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 1px solid rgba(245, 158, 11, 0.25);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.search-box {
    position: relative;
    min-width: 200px;
}

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

@media (max-width: 1200px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-subnav {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-menu.horizontal {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .admin-main {
        padding: 16px 0 40px;
    }

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

    .admin-filters {
        width: 100%;
        gap: 8px;
    }

    .admin-filters .search-box {
        flex: 1;
        min-width: 0;
    }

    .admin-filters .select-input,
    .admin-filters .btn {
        width: 100%;
    }

    .text-input,
    .select-input,
    .text-area {
        font-size: 16px;
    }

    .admin-nav .nav-container {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .admin-nav-right {
        width: 100%;
        justify-content: space-between;
    }

    .admin-kpis {
        grid-template-columns: 1fr 1fr;
    }

    /* Transform Table to Cards on Mobile */
    .admin-table-wrap {
        border: none;
        box-shadow: none;
        background: transparent;
        overflow-x: visible;
    }

    .admin-table thead,
    .admin-table thead tr,
    .admin-table thead th {
        display: none !important;
    }

    .admin-table,
    .admin-table thead,
    .admin-table tbody,
    .admin-table th,
    .admin-table td,
    .admin-table tr {
        display: block;
    }

    .admin-table tr {
        background: #FFFFFF;
        border: 1px solid var(--border);
        border-radius: 16px;
        margin-bottom: 12px;
        padding: 8px;
        box-shadow: var(--shadow-sm);
        position: relative;
        width: min(100%, 560px);
        margin-left: auto;
        margin-right: auto;
    }

    .admin-table td {
        border: none;
        position: relative;
        padding: 8px 12px 8px 110px !important;
        min-height: 38px;
        display: flex;
        align-items: center;
        text-align: left;
    }

    .admin-table td:before {
        position: absolute;
        left: 12px;
        width: 90px;
        white-space: nowrap;
        font-weight: 700;
        font-size: 0.7rem;
        color: var(--gray);
        text-transform: uppercase;
        content: attr(data-label);
    }

    .admin-table td:first-child {
        padding-left: 12px !important;
        border-bottom: 1px solid var(--border);
        margin-bottom: 4px;
        background: rgba(245, 158, 11, 0.05);
        border-radius: 8px 8px 0 0;
    }

    .admin-table td:first-child:before {
        display: none;
    }

    .affiliates-table td {
        padding-left: 12px !important;
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
        min-height: auto;
    }

    .affiliates-table td:before {
        position: static;
        width: auto;
        margin-bottom: 2px;
    }

    .affiliates-table td:first-child {
        display: none;
    }

    .detail-kv {
        grid-template-columns: 100px 1fr;
    }

    .thumbs {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-detail {
        display: none;
    }

    .admin-media-grid {
        grid-template-columns: 1fr;
    }

    .admin-media-grid .admin-card {
        width: 100%;
        max-width: 560px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 480px) {
    .admin-kpis {
        grid-template-columns: 1fr;
    }

    .admin-subnav {
        padding: 16px;
    }

    .admin-side-brand {
        justify-content: center;
        flex-direction: column;
        text-align: center;
    }

    .admin-menu-btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
        font-size: 0.8rem;
    }

    .detail-kv {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .detail-kv .k {
        font-size: 0.75rem;
    }
}
