/* ============================================================
   CrochetPDF — Global Stylesheet
   ============================================================ */

/* CSS Variables */
:root {
    --primary: #D94F3D;
    --primary-dark: #b83e2f;
    --primary-light: #fff0ee;
    --secondary: #4A7C59;
    --secondary-light: #e8f5ec;
    --dark: #2d2d2d;
    --light-bg: #faf7f5;
    --card-bg: #ffffff;
    --border: #f0ebe6;
    --text: #2d2d2d;
    --text-muted: #888;
    --warning: #f5d87a;
    --warning-bg: #fef9e7;
    --success: #4A7C59;
    --success-bg: #e8f5ec;
    --danger: #D94F3D;
    --danger-bg: #fff0ee;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow: 0 2px 16px rgba(0,0,0,0.07);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --transition: all 0.2s ease;
    --font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --sidebar-width: 240px;
    --max-width: 1200px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--text);
    background: var(--light-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--dark);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-family);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

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

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

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

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

.btn-secondary:hover {
    background: #3d6a4a;
    border-color: #3d6a4a;
    color: #fff;
}

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

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

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

.btn-outline-secondary:hover {
    background: var(--secondary);
    color: #fff;
}

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

.btn-danger:hover {
    background: #c43a2a;
    border-color: #c43a2a;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--border);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.05rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

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

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: var(--font-family);
    color: var(--text);
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(217, 79, 61, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #bbb;
}

.form-group .form-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.5;
}

.alert a {
    font-weight: 700;
    text-decoration: underline;
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(217, 79, 61, 0.2);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(74, 124, 89, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: #92600a;
    border: 1px solid rgba(245, 216, 122, 0.4);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: var(--transition);
}

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

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

.card-header h2,
.card-header h3 {
    font-size: 1.1rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

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

thead th {
    background: var(--light-bg);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(250, 247, 245, 0.5);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: #92600a;
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-muted {
    background: #f0f0f0;
    color: var(--text-muted);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition);
    border: 1px solid var(--border);
}

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

.stat-card .stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1.2;
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.stat-card.stat-danger {
    border-color: rgba(217, 79, 61, 0.3);
    background: var(--danger-bg);
}

.stat-card.stat-danger .stat-value {
    color: var(--danger);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--dark);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
    max-width: 360px;
}

.toast-success {
    background: var(--secondary);
}

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

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

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: scaleIn 0.2s ease;
}

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

.modal-body {
    padding: 24px;
}

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

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

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

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-dark {
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--primary);
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 100px;
    transition: width 0.4s ease;
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font-family);
}

.tab-btn:hover {
    color: var(--text);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 600;
    transition: var(--transition);
}

.pagination a {
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.pagination a:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
}

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

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--dark);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .btn-lg {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
