/* ===== ADMIN PANEL - Store-Matching Design ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #1665af;
    --primary-dark: #1373d3;
    --secondary: #2EC4B6;
    --accent: #5ac8fa;
    --light: #FFFFFF;
    --light-gray: #F8F9FA;
    --medium-gray: #E9ECEF;
    --dark-gray: #6C757D;
    --text-dark: #212529;
    --text-muted: #6C757D;
    --gradient-1: linear-gradient(135deg, #166fc2 0%, #188fc7 100%);
    --gradient-2: linear-gradient(135deg, #2EC4B6 0%, #38D9A9 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #e5e7eb;
    --border-green: #10b981;
    --border-green-light: rgba(16, 185, 129, 0.75);
    --border-green-input: rgba(16, 185, 129, 0.35);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--light-gray);
    color: var(--text-dark);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== LOGIN ===== */
#login-overlay {
    position: fixed;
    inset: 0;
    background: var(--gradient-1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--light);
    padding: 40px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card h1 { font-size: 22px; margin-bottom: 8px; color: var(--text-dark); font-weight: 700; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.input-group { text-align: left; margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-dark); }
.input-group input {
    width: 100%;
    border: 1.2px solid var(--border-green-input);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: all 0.2s;
}
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(22, 101, 175, 0.1); }

.btn-login {
    width: 100%;
    background: var(--gradient-1);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ===== HEADER ===== */
header {
    background: var(--light);
    border-bottom: 2px solid var(--border-green-light);
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.logo {
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
}

.user-info { display: flex; align-items: center; gap: 12px; }

.btn-logout {
    background: var(--light);
    border: 1px solid var(--medium-gray);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* ===== MAIN ===== */
main { max-width: 900px; margin: 0 auto; padding: 32px 20px; }

.section-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.btn-add {
    background: var(--gradient-1);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-add:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ===== EDIT PLATFORM MODAL ===== */
.edit-modal-box {
    width: 680px;
    max-width: 96vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    overflow: hidden;
    padding: 0;
    background: white;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    border: 4px solid var(--border-green);
}

.edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1.5px solid var(--border-green-light);
    background: var(--light);
    flex-shrink: 0;
}

.edit-modal-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.edit-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
}

.edit-modal-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-green-input);
}

.status-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

@media (max-width: 600px) {
    .edit-modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
    }
    .edit-modal-header-actions {
        width: 100%;
        gap: 8px;
    }
    .edit-modal-header-actions .btn-save, 
    .edit-modal-header-actions .btn-cancel {
        flex: 1;
        padding: 10px 12px;
        font-size: 13px;
        justify-content: center;
    }
    .edit-modal-body {
        padding: 20px;
    }
}

.btn-edit-platform {
    background: var(--light);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
}
.btn-edit-platform:hover { background: var(--primary); color: white; }

/* ===== PLATFORM LIST ===== */
.platform-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
    position: relative;
}

.platform-item {
    background: var(--light);
    border: 1.5px solid var(--border-green-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.25s ease;
    position: relative;
    z-index: 1;
}
.platform-item:hover { 
    box-shadow: var(--shadow-sm); 
    border-color: var(--border-green);
}

.platform-item.is-dragging {
    position: fixed;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0.95;
    transition: none;
    border: 2px solid var(--primary);
}

.platform-item.drag-placeholder {
    opacity: 0;
    pointer-events: none;
}

.platform-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    gap: 14px;
    cursor: pointer;
    user-select: none;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px 6px;
    opacity: 0.3;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
    line-height: 1;
    touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.platform-item:hover .drag-handle { opacity: 0.7; color: var(--primary); }

.platform-row img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--medium-gray);
    flex-shrink: 0;
}

.platform-row-info { flex: 1; min-width: 0; }
.platform-row-info .p-name { font-weight: 600; font-size: 15px; color: var(--text-dark); }
.platform-row-info .p-desc { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.platform-row-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.platform-row-meta .p-price { font-weight: 700; color: var(--primary); font-size: 15px; }

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--error); }

.expand-icon {
    font-size: 18px;
    color: var(--text-muted);
    transition: transform 0.3s;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}
.platform-item.expanded .expand-icon { transform: rotate(180deg); }

/* ===== EXPANDABLE EDIT PANEL ===== */
.platform-edit {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background: var(--light-gray);
    border-top: 1px solid var(--medium-gray);
}
.platform-item.expanded .platform-edit { max-height: 800px; }

.platform-edit-inner { padding: 20px; }

.form-row { margin-bottom: 14px; }
.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-row input, .form-row textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.2px solid var(--border-green-input);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: all 0.2s;
    background: white;
}
.form-row input:focus, .form-row textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 101, 175, 0.1);
}

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

.image-action-row { display: flex; align-items: stretch; gap: 8px; }
.image-action-row .file-upload-wrapper { margin-bottom: 0; flex-shrink: 0; width: 40px; }
.image-action-row .file-upload-btn { width: 40px; border-radius: var(--radius-sm); }
.image-action-row .file-upload-btn span { display: none; }
.image-action-row input { flex: 1; min-width: 0; }
.btn-copy {
    background: var(--light);
    border: 1px solid var(--medium-gray);
    color: var(--text-muted);
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover { border-color: var(--primary); color: var(--primary); background: #eef6ff; }

/* ===== TOGGLE ===== */
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toggle-row span { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.toggle-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 22px; cursor: pointer; transition: .3s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s; }
input:checked + .slider { background: var(--success); }
input:checked + .slider:before { transform: translateX(18px); }

/* ===== FILE UPLOAD ===== */
.file-upload-wrapper { margin-bottom: 8px; position: relative; }
.file-upload-input { width: 100%; height: 40px; opacity: 0; cursor: pointer; position: absolute; z-index: 2; }
.file-upload-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--light); border: 1px dashed var(--medium-gray); border-radius: var(--radius-sm);
    height: 40px; font-size: 13px; font-weight: 600; color: var(--text-muted);
    transition: all 0.2s;
}
.file-upload-wrapper:hover .file-upload-btn { border-color: var(--primary); color: var(--primary); background: #eef6ff; }

/* ===== EDIT ACTIONS ===== */
.edit-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--light); justify-content: flex-end; }
.btn-save { background: var(--primary); color: white; border: none; padding: 10px 24px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.2s; }
.btn-save:hover { background: #0056b3; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2); }

.btn-cancel { background: #fef2f2; color: #b91c1c; border: 1px solid #fee2e2; padding: 9px 20px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: 'Poppins', sans-serif; font-size: 14px; display: flex; align-items: center; justify-content: center; line-height: 1; }
.btn-cancel:hover { background: #fee2e2; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1); }

.btn-delete-top { background: transparent; color: #ff4d4d; border: 1px solid rgba(255, 77, 77, 0.2); width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s; }
.btn-delete-top:hover { background: #fff5f5; border-color: #ff4d4d; }

.btn-delete {
    background: #fef2f2;
    color: var(--error);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-delete:hover { background: var(--error); color: white; border-color: var(--error); }

.btn-reset-pricing { 
    background: transparent; 
    color: var(--primary); 
    border: 1px solid rgba(0, 102, 255, 0.2); 
    padding: 6px 12px; 
    border-radius: var(--radius-sm); 
    font-size: 11px; 
    font-weight: 700; 
    cursor: pointer; 
    transition: all 0.2s; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
}
.btn-reset-pricing:hover { background: #eef6ff; border-color: var(--primary); }

/* ===== SETTINGS ===== */
.settings-card {
    background: var(--light);
    border: 1.5px solid var(--border-green-light);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.2s;
}
.settings-card:hover { border-color: var(--border-green); }
.settings-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: var(--text-dark); }

.setting-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.setting-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1.2px solid var(--border-green-input);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: white;
}

.setting-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 101, 175, 0.1);
}

.discount-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.discount-item { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--text-dark); font-size: 14px; }
.discount-item .discount-label { flex: 1; text-align: center; min-width: 80px; color: var(--text-muted); font-size: 13px; }
.discount-item input {
    padding: 8px 10px;
    border: 1.2px solid var(--border-green-input);
    border-radius: var(--radius-sm);
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}
.discount-qty-input { width: 65px; text-align: center; }
.discount-value-input { width: 90px; text-align: right; }
.discount-item input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 101, 175, 0.1); }
.discount-item input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 101, 175, 0.1); }

/* ===== ADD MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-card {
    background: var(--light);
    border-radius: var(--radius-lg);
    border: 4px solid var(--border-green);
    overflow: hidden;
    padding: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}
.modal-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

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

/* ===== TOAST ===== */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    transform: translateY(100px);
    transition: transform 0.3s;
    z-index: 3000;
    box-shadow: var(--shadow-md);
}
#toast.show { transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--primary); }

/* ===== PRICING GRID ===== */
.pricing-grid-wrapp.settings-card {
    background: var(--light);
    padding: 24px 28px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    border: 1.5px solid var(--border-green-light);
    transition: border-color 0.2s;
}
.settings-card:hover {
    border-color: var(--border-green);
}
.pricing-grid-wrapper {
    background: #f1f3f5;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    border: 1px solid var(--medium-gray);
    overflow-x: auto;
}
.pricing-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
}
.pricing-table th {
    padding: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: center;
    border-bottom: 2px solid var(--medium-gray);
}
.pricing-table td {
    padding: 6px;
    text-align: center;
}
.pricing-table td:first-child {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
}
.pricing-table input {
    width: 90px;
    padding: 6px 8px;
    font-size: 13px;
    text-align: right;
    border: 1.2px solid var(--border-green-input);
    border-radius: 4px;
    outline: none;
    transition: all 0.2s;
}
.pricing-table input:focus { border-color: var(--primary); background: #f0f7ff; box-shadow: 0 0 0 3px rgba(22, 101, 175, 0.1); }

.add-discount-btn {
    background: var(--light);
    border: 1px solid var(--medium-gray);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.add-discount-btn:hover { background: #eef6ff; border-color: var(--primary); }

.discount-item .btn-remove {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.discount-item .btn-remove:hover { opacity: 1; }

.pricing-notice {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-style: italic;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    header { padding: 14px 16px; }
    main { padding: 20px 12px; }
    .form-grid { grid-template-columns: 1fr; }
    .discount-grid { grid-template-columns: 1fr; }

    /* --- Platform cards: two-row layout on mobile --- */
    .platform-row {
        flex-wrap: wrap;
        padding: 10px 14px;
        gap: 8px;
    }

    /* Drag handle visible on mobile with larger touch area */
    .drag-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        padding: 5px;
        opacity: 0.5;
        border-radius: var(--radius-sm);
        background: var(--light-gray);
        border: 1px solid var(--medium-gray);
        touch-action: none;
        flex-shrink: 0;
    }
    .drag-handle:active {
        opacity: 1;
        background: #e0f2fe;
        border-color: var(--primary);
    }

    .platform-row img {
        width: 32px;
        height: 32px;
    }

    .platform-row-info {
        flex: 1;
        min-width: 0;
    }
    .platform-row-info .p-name { font-size: 14px; }
    .platform-row-info .p-desc { font-size: 11px; }

    /* Meta row: full width, compact */
    .platform-row-meta {
        width: 100%;
        justify-content: flex-end;
        gap: 10px;
        padding-top: 2px;
    }
    .platform-row-meta .p-price {
        font-size: 14px;
        margin-right: auto;
    }

    .modal-card { padding: 24px 16px; }
    .form-grid-3 { grid-template-columns: 1fr; }
    .image-action-row { flex-wrap: wrap; }
    .image-action-row input { min-width: 150px; }
    .edit-modal-box { max-height: 90vh; }
    .pricing-grid-wrapper { padding: 8px; }
    .pricing-table input { width: 75px; padding: 4px 6px; font-size: 12px; }
    .pricing-table th, .pricing-table td:first-child { font-size: 10px; }
}
