/**
 * WP Stock Manager - Styles complets
 * Version: 1.0.0
 * Design moderne, responsive et accessible
 */

/* ============================================
   Variables CSS
   ============================================ */
:root {
    --primary: #2271b1;
    --primary-dark: #135e96;
    --primary-light: #4a90d9;
    --success: #00a32a;
    --success-light: #d4f4dd;
    --warning: #f0b849;
    --warning-light: #fcf4e3;
    --danger: #d63638;
    --danger-light: #f4d4d4;
    --info: #3858e9;
    --info-light: #d4e4f4;
    --dark: #1e1e1e;
    --light: #f6f7f7;
    --border: #dcdcde;
    --text: #2c3338;
    --text-light: #50575e;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
    --spacing: 20px;
}

/* Dark theme */
[data-theme="dark"] {
    --primary: #4a90d9;
    --bg: #1e1e1e;
    --text: #f0f0f0;
    --border: #444;
}

/* ============================================
   Reset et base
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, 'Helvetica Neue', sans-serif;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Container principal
   ============================================ */
.wsm-app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing);
}

.wsm-app {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-height: 600px;
}

/* Loading state */
.wsm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-light);
}

.wsm-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Header
   ============================================ */
.wsm-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: var(--spacing);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wsm-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.user-info {
    font-size: 14px;
    opacity: 0.9;
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: var(--radius);
}

/* ============================================
   Navigation / Tabs
   ============================================ */
.wsm-tabs {
    display: flex;
    background: var(--light);
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab:hover {
    background: rgba(0,0,0,0.03);
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: white;
}

/* ============================================
   Content area
   ============================================ */
.wsm-content {
    padding: var(--spacing);
    min-height: 400px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing);
    margin-bottom: var(--spacing);
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text);
}

/* ============================================
   Forms
   ============================================ */
.form-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: white;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
}

/* ============================================
   Buttons
   ============================================ */
.button {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.button-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

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

.button-secondary:hover:not(:disabled) {
    background: var(--border);
}

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

.button-danger:hover:not(:disabled) {
    background: #b32d2e;
}

.button-small {
    padding: 6px 12px;
    font-size: 13px;
}

.button-icon {
    padding: 8px;
    min-width: 36px;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

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

/* ============================================
   Lists
   ============================================ */
.list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    background: white;
    transition: var(--transition);
}

.list-item:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 600;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-details {
    font-size: 13px;
    color: var(--text-light);
    display: flex;
    gap: 15px;
}

.item-stock {
    text-align: center;
    padding: 10px;
    background: var(--light);
    border-radius: var(--radius);
    min-width: 80px;
}

.stock-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--success);
    display: block;
}

.stock-value.low-stock {
    color: var(--danger);
}

.item-actions {
    display: flex;
    gap: 5px;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-ongoing {
    background: var(--warning-light);
    color: var(--warning);
}

.status-returned {
    background: var(--success-light);
    color: var(--success);
}

.status-late {
    background: var(--danger-light);
    color: var(--danger);
}

/* ============================================
   Search bar
   ============================================ */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: var(--spacing);
}

.search-bar input {
    flex: 1;
}

/* ============================================
   Movements
   ============================================ */
.movements-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.movement-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.movement-in {
    background: var(--success-light);
    border-color: var(--success);
}

.movement-out {
    background: var(--danger-light);
    border-color: var(--danger);
}

.movement-icon {
    font-size: 24px;
}

.movement-info {
    flex: 1;
}

.movement-info strong {
    display: block;
    margin-bottom: 2px;
}

.movement-info small {
    color: var(--text-light);
    font-size: 12px;
}

.movement-qty {
    font-weight: bold;
    font-size: 16px;
}

.movement-note {
    width: 100%;
    padding: 8px;
    background: white;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-top: 8px;
}

/* ============================================
   Rentals
   ============================================ */
.rentals-list {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.rental-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    background: white;
}

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

.rental-details {
    font-size: 14px;
    line-height: 1.8;
}

.rental-details div {
    padding: 2px 0;
}

.rental-item.status-ongoing {
    border-left: 4px solid var(--warning);
}

.rental-item.status-returned {
    border-left: 4px solid var(--success);
}

.rental-item.status-late {
    border-left: 4px solid var(--danger);
}

/* ============================================
   Notifications
   ============================================ */
.wsm-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.wsm-notification.show {
    transform: translateX(0);
}

.wsm-notification-success {
    background: var(--success);
}

.wsm-notification-error {
    background: var(--danger);
}

.wsm-notification-warning {
    background: var(--warning);
}

.wsm-notification-info {
    background: var(--info);
}

/* ============================================
   Empty states
   ============================================ */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.error {
    padding: 20px;
    background: var(--danger-light);
    color: var(--danger);
    border-radius: var(--radius);
    text-align: center;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-light);
}

/* ============================================
   Scanner
   ============================================ */
#scanner-container,
#mv-scanner {
    padding: 20px;
    background: var(--light);
    border-radius: var(--radius);
    text-align: center;
    margin: 15px 0;
}

#scanner-container video,
#mv-scanner video {
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.resolve-info {
    margin-top: 10px;
    padding: 10px;
    background: var(--info-light);
    border-radius: var(--radius);
    font-size: 13px;
    display: none;
}

.resolve-info:not(:empty) {
    display: block;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .wsm-app-container {
        padding: 10px;
    }
    
    .wsm-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .wsm-tabs {
        overflow-x: auto;
    }
    
    .tab {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .list-item {
        flex-direction: column;
        text-align: center;
    }
    
    .item-actions {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    .rentals-list {
        grid-template-columns: 1fr;
    }
    
    .wsm-notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }
    
    .wsm-notification.show {
        transform: translateY(0);
    }
}

/* ============================================
   Print styles
   ============================================ */
@media print {
    .wsm-header,
    .wsm-tabs,
    .button,
    .btn-icon,
    .search-bar,
    .add-product-card,
    .add-movement-card,
    .add-rental-card {
        display: none !important;
    }
    
    .wsm-app {
        box-shadow: none;
        border-radius: 0;
    }
    
    .list-item {
        page-break-inside: avoid;
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible pour accessibilité clavier */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}