/* ============================================
   Masala Platform - Custom Styles
   Design inspired by modern dashboard UI
   ============================================ */

/* ---- CSS Variables / Design Tokens ---- */
:root {
    --primary: #E8654A;
    --primary-light: #fef3f0;
    --primary-dark: #d14a30;
    --dark: #1A1A2E;
    --warm: #F4A261;
    --surface: #F8F6F3;
    --card-bg: #ffffff;
    --card-radius: 16px;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --sidebar-width: 256px;
    --transition: 0.2s ease;
}

/* ---- Animations ---- */
@keyframes slideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

.animate-slide-in { animation: slideIn 0.3s ease-out; }
.animate-fade-in { animation: fadeIn 0.4s ease-out; }
.animate-scale-in { animation: scaleIn 0.3s ease-out; }
.animate-counter { animation: counter 0.5s ease-out; }

/* Staggered animation for cards */
.stagger-in > * {
    opacity: 0;
    animation: fadeIn 0.4s ease-out forwards;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.10s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.20s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.30s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.40s; }

/* ---- Flash Messages ---- */
.flash-success { background: rgba(240, 253, 244, 0.95); border: 1px solid #bbf7d0; }
.flash-error { background: rgba(254, 242, 242, 0.95); border: 1px solid #fecaca; }
.flash-info { background: rgba(239, 246, 255, 0.95); border: 1px solid #bfdbfe; }
.flash-warning { background: rgba(255, 251, 235, 0.95); border: 1px solid #fde68a; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 40;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 12px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(232, 101, 74, 0.4);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
    opacity: 1;
}

.sidebar-section {
    padding: 20px 16px 8px 28px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-stat {
    padding: 24px;
}

.card-stat .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.card-stat .stat-label {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
    font-weight: 500;
}

.card-stat .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-stat .stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 8px;
}

.stat-change.up { background: #dcfce7; color: #16a34a; }
.stat-change.down { background: #fee2e2; color: #dc2626; }

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    border-bottom: 1px solid #f3f4f6;
    background: #fafafa;
}

.data-table thead th:first-child { border-radius: 12px 0 0 0; }
.data-table thead th:last-child { border-radius: 0 12px 0 0; }

.data-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid #f9fafb;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

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

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    transition: all var(--transition);
    background: #fff;
    color: #1f2937;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 101, 74, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 40px;
}

/* ---- 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;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(232, 101, 74, 0.35);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

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

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

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

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 8px;
}

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

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.25s ease-out;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

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

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---- Pagination ---- */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background: #fff;
    border: 1px solid #e5e7eb;
    text-decoration: none;
    transition: all 0.15s ease;
}

.page-link:hover {
    background: #f3f4f6;
    color: #374151;
}

.page-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-dots {
    display: flex;
    align-items: center;
    padding: 0 4px;
    color: #9ca3af;
}

/* ---- Product Card ---- */
.product-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.product-card .product-image {
    aspect-ratio: 1;
    overflow: hidden;
    background: #f8f8f8;
}

.product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-card .product-info {
    padding: 16px;
}

.product-card .product-brand {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
}

.product-card .product-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-top: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .product-description {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .product-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 8px;
}

.product-card .product-price .current {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
}

.product-card .product-price .original {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: line-through;
}

.product-card .product-price .discount {
    font-size: 11px;
    font-weight: 600;
    color: #16a34a;
    background: #dcfce7;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 35;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Loading Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state svg {
    margin: 0 auto 16px;
    color: #d1d5db;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: #6b7280;
}

.empty-state p {
    font-size: 14px;
    color: #9ca3af;
    margin-top: 4px;
}

/* ---- Chart Containers ---- */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ---- Status Dots ---- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background: #22c55e; }
.status-dot.inactive { background: #9ca3af; }
.status-dot.pending { background: #f59e0b; }
