/* 
 * RetoursPro - Design System (Vanilla CSS)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Palette Light Components */
    --primary-h: 217;
    --primary-s: 91%;
    --primary-l: 60%;
    
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-foreground: hsl(0, 0%, 100%);
    --background: hsl(0, 0%, 100%);
    --foreground: hsl(222, 47%, 11%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(222, 47%, 11%);
    --popover: hsl(0, 0%, 100%);
    --popover-foreground: hsl(222, 47%, 11%);
    --muted: hsl(210, 40%, 96%);
    --muted-foreground: hsl(215, 16%, 47%);
    --accent: hsl(210, 40%, 96%);
    --accent-foreground: hsl(222, 47%, 11%);
    --destructive: hsl(0, 72%, 51%);
    --destructive-foreground: hsl(210, 40%, 98%);
    --success: hsl(142, 71%, 45%);
    --info: hsl(199, 89%, 48%);
    --warning: hsl(38, 92%, 50%);
    --border: hsl(214, 32%, 91%);
    --input: hsl(214, 32%, 91%);
    --ring: var(--primary);
    
    /* Sidebar Specific */
    --sidebar-background: hsl(222, 47%, 11%);
    --sidebar-foreground: hsl(210, 40%, 98%);
    --sidebar-accent: hsl(217, 33%, 17%);
    --sidebar-primary: var(--primary);
    
    --radius: 0.5rem;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
}

.dark {
    --background: hsl(222, 47%, 11%);
    --foreground: hsl(210, 40%, 98%);
    --card: hsl(222, 47%, 11%);
    --card-foreground: hsl(210, 40%, 98%);
    --popover: hsl(222, 47%, 11%);
    --popover-foreground: hsl(210, 40%, 98%);
    --muted: hsl(217, 33%, 17%);
    --muted-foreground: hsl(215, 20.2%, 65.1%);
    --accent: hsl(217, 33%, 17%);
    --accent-foreground: hsl(210, 40%, 98%);
    --border: hsl(217, 33%, 17%);
    --input: hsl(217, 33%, 17%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-background);
    color: var(--sidebar-foreground);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: var(--sidebar-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.25rem;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--sidebar-foreground);
    opacity: 0.7;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-item:hover, .nav-item.active {
    opacity: 1;
    background-color: var(--sidebar-accent);
}

.nav-item.active {
    color: var(--sidebar-primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
}

.nav-label {
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-accent);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: color 0.2s;
}

.form-group:focus-within label {
    color: var(--primary);
}

.form-group label i {
    width: 14px;
    height: 14px;
    opacity: 0.8;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--background);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    color: var(--foreground);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
}

.form-control:hover {
    border-color: var(--muted-foreground);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--background);
    box-shadow: 0 4px 12px -2px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.15);
    transform: translateY(-1px);
}

.form-control::placeholder {
    color: var(--muted-foreground);
    opacity: 0.5;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* UI Components */
.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 0.5rem;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    opacity: 0.9;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--foreground);
}

.btn-outline:hover {
    background-color: var(--accent);
}

.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background-color: hsla(142, 71%, 45%, 0.1); color: var(--success); }
.badge-warning { background-color: hsla(38, 92%, 50%, 0.1); color: var(--warning); }
.badge-destructive { background-color: hsla(0, 72%, 51%, 0.1); color: var(--destructive); }

/* Table */
.table-container {
    width: 100%;
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

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

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-content {
    background-color: var(--card);
    width: 100%;
    max-width: 850px;
    border-radius: 1.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.modal-header {
    padding: 1.5rem 2.5rem;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    flex-shrink: 0;
}

.modal-body {
    padding: 2.5rem;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.modal-footer {
    padding: 1.5rem 2.5rem;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1.25rem;
    background: var(--card);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .modal-backdrop {
        padding: 0.5rem;
    }
    .modal-header, .modal-body, .modal-footer {
        padding: 1.25rem;
    }
    .modal-grid-2 {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
}

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

/* Animations */
.animate-fade-in { animation: fade-in 0.4s ease-out; }
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

.pulse-warning {
    animation: pulse-warning 1.5s infinite;
}

@keyframes pulse-warning {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.group-header:hover {
    background-color: var(--accent) !important;
}

.chevron-icon {
    color: var(--muted-foreground);
}

.group-header:hover .chevron-icon {
    color: var(--primary);
}

/* Responsive Grid Helpers */
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.grid-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .grid-2-1, .grid-1-2 {
        grid-template-columns: 1fr;
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* Mobile Top Navigation Styles */
.mobile-nav {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background-color: var(--sidebar-background);
    color: var(--sidebar-foreground);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--sidebar-accent);
}

.mobile-nav-toggle {
    background: none;
    border: none;
    color: currentColor;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.mobile-nav-toggle:hover {
    background-color: var(--sidebar-accent);
}

.mobile-nav-title {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 45;
    animation: fade-in 0.25s ease-out;
}

/* Responsiveness */
@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        height: 100vh;
        z-index: 50;
        top: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem 1rem !important;
        margin-top: 60px; /* Espace pour le header mobile */
    }
}
