/**
 * DTF Swiss Editor - Styles Custom
 * Complément aux classes TailwindCSS
 */

/* Variables CSS pour cohérence */
:root {
    --dtf-dark: #1a1a2e;
    --dtf-sidebar: #16213e;
    --dtf-canvas: #2a2a3e;
    --dtf-blue: #57b5e7;
    --dtf-blue-hover: #3b92cf;
}

/* Base */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* PAS de scroll sur la page */
    font-family: 'Poppins', sans-serif;
    user-select: none;
}

/* Canvas wrapper Fabric.js — centré dans la zone */
#canvas-zone .canvas-container {
    margin: auto !important;
    position: relative !important;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Canvas principal */
#main-canvas {
    border: 1px solid #666;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    cursor: crosshair;
}

/* Fond damier (transparence) */
.canvas-bg-checker .canvas-container {
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #fff;
}

/* Fond damier sombre */
.canvas-bg-checker.canvas-bg-dark .canvas-container {
    background-image:
        linear-gradient(45deg, #333 25%, transparent 25%),
        linear-gradient(-45deg, #333 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #333 75%),
        linear-gradient(-45deg, transparent 75%, #333 75%);
    background-color: #444;
}

/* Fond blanc uni */
.canvas-bg-white .canvas-container {
    background-color: #ffffff;
    background-image: none;
}

/* Fond sombre uni */
.canvas-bg-dark .canvas-container {
    background-color: #1a1a2e;
    background-image: none;
}

/* Zone de drop pour drag & drop */
#drop-zone {
    border-color: var(--dtf-blue);
    background-color: rgba(0, 0, 0, 0.8);
    transition: opacity 0.2s ease;
}

#drop-zone.drag-over {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}

/* Sidebar droite scrollable */
.w-70 {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast-success { background: #10b981; }
.toast-info { background: #3b82f6; }
.toast-warning { background: #f59e0b; }
.toast-error { background: #ef4444; }

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

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Canvas curseur */
#canvas-zone .canvas-container canvas {
    cursor: crosshair !important;
}

/* Bordure subtile autour du canvas */
#canvas-zone .canvas-container {
    box-shadow: 0 0 0 2px rgba(87, 181, 231, 0.3), 0 4px 20px rgba(0,0,0,0.4) !important;
    border-radius: 2px;
}

/* Modal raccourcis */
.shortcuts-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.shortcuts-content {
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #334155;
    font-size: 13px;
}

.shortcut-key {
    background: #334155;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* Boutons hover pulse */
button:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

/* Sidebar personnalisations */
.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #374151;
}

.sidebar-section:last-child {
    border-bottom: none;
}

/* Boutons personnalisés */
.btn-primary {
    background-color: var(--dtf-blue);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--dtf-blue-hover);
}

.btn-primary:disabled {
    background-color: #6b7280;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.btn-warning {
    background-color: #f59e0b;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-success {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-success:hover {
    background-color: #059669;
}

/* Inputs personnalisés */
.input-field {
    background-color: var(--dtf-dark);
    border: 1px solid #6b7280;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: border-color 0.2s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--dtf-blue);
    box-shadow: 0 0 0 3px rgba(87, 181, 231, 0.1);
}

.input-field::-webkit-outer-spin-button,
.input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-field[type=number] {
    -moz-appearance: textfield;
}

/* Select personnalisé */
.select-field {
    background-color: var(--dtf-dark);
    border: 1px solid #6b7280;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: border-color 0.2s ease;
    cursor: pointer;
}

.select-field:focus {
    outline: none;
    border-color: var(--dtf-blue);
    box-shadow: 0 0 0 3px rgba(87, 181, 231, 0.1);
}

/* Checkbox personnalisé */
.checkbox-field {
    accent-color: var(--dtf-blue);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.2s ease-in-out;
}

.fade-out {
    animation: fadeOut 0.2s ease-in-out;
}

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

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

/* Indicateurs DPI */
.dpi-indicator {
    border-radius: 50%;
    width: 12px;
    height: 12px;
}

.dpi-excellent { background-color: #10b981; }
.dpi-good { background-color: #f59e0b; }
.dpi-poor { background-color: #ef4444; }

/* Loading states */
.loading {
    opacity: 0.6;
    cursor: wait;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive adjustments */
@media (max-width: 1024px) {
    .w-48 {
        width: 10rem; /* Sidebar plus étroite sur tablette */
    }
    
    .w-70 {
        width: 16rem; /* Propriétés plus étroites sur tablette */
    }
}

@media (max-width: 768px) {
    /* Mobile: sidebars en overlay */
    .sidebar-mobile {
        position: fixed;
        top: 4rem;
        bottom: 3rem;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar-mobile.open {
        transform: translateX(0);
    }
    
    .mobile-backdrop {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }
}

/* Scrollbars personnalisées */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dtf-sidebar);
}

::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Focus visible pour accessibilité */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--dtf-blue);
    outline-offset: 2px;
}

/* Tooltip custom */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Fabric.js customizations */
.canvas-container .upper-canvas {
    cursor: crosshair !important;
}

.canvas-container .upper-canvas:hover {
    cursor: pointer !important;
}