/* ============================================
   COMPONENTS — Buttons, Forms, Tables, etc.
   ============================================ */

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

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

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

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

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--cream-deep);
    color: var(--text-primary);
}

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

.btn-danger:hover { background: #963028; border-color: #963028; color: white; }

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

.btn-block { display: flex; width: 100%; }

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.btn-icon:hover {
    opacity: 1;
    background: var(--bg-hover);
}

/* Action Buttons (table rows) */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text-secondary);
}

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

.btn-action-view:hover  { background: var(--primary);  color: white; border-color: var(--primary); }
.btn-action-edit:hover  { background: var(--warning);  color: white; border-color: var(--warning); }
.btn-action-delete:hover{ background: var(--danger);   color: white; border-color: var(--danger);  }
.btn-action-pdf:hover   { background: var(--success);  color: white; border-color: var(--success); }

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: var(--bg-input);
    color: var(--text-primary);
    line-height: 1.5;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
    border-color: var(--cream-deep);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.12);
}

input::placeholder,
textarea::placeholder { color: var(--text-muted); }

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

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239A8478' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

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

.form-section,
.form-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.form-section h3,
.form-card h3 {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}

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

.section-header h3 { margin: 0; padding: 0; border: 0; }

.link-small {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    display: inline-block;
    margin-top: 6px;
    font-weight: 500;
}

/* Customer Autocomplete */
.autocomplete-wrapper,
.customer-search-wrapper { position: relative; }

.customer-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
    display: none;
}

.customer-suggestions.active { display: block; }

.customer-suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-light);
}

.customer-suggestion-item:hover { background: var(--bg-hover); }
.customer-suggestion-item:last-child { border-bottom: none; }

.customer-suggestion-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.customer-suggestion-details {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- TABLES --- */
.table-responsive {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
}

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

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table thead { background: var(--cream-dark); }

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'DM Sans', sans-serif;
}

.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.order-row:hover { background: var(--primary-100); }

.data-table .actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
}

.data-table a { color: var(--primary); font-weight: 500; }

/* --- TOASTS --- */
#toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    min-width: 280px;
    max-width: 400px;
    pointer-events: all;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid var(--border);
}

.toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--bg-card);
    color: var(--text-primary);
    border-left: 4px solid var(--success);
}

.toast-error {
    background: var(--bg-card);
    color: var(--text-primary);
    border-left: 4px solid var(--danger);
}

.toast-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: var(--success-light);
    color: var(--success);
}

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

.toast-message { flex: 1; }

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.toast-close:hover { color: var(--text-primary); }

/* --- ALERTS (only keep for inline error-message, login errors etc.) --- */
.alert {
    padding: 14px 18px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    transition: opacity 0.3s;
    font-weight: 500;
    font-size: 14px;
    border-left: 3px solid;
    animation: alertSlideIn 0.3s ease;
}

.alert-success {
    background: var(--success-light);
    color: #3a5a2c;
    border-left-color: var(--success);
}

.alert-error {
    background: var(--danger-light);
    color: #8a2c24;
    border-left-color: var(--danger);
}

.error-message {
    background: var(--danger-light);
    color: #8a2c24;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border-left: 3px solid var(--danger);
    font-size: 14px;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- BADGES --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-primary  { background: var(--primary-100); color: var(--primary-dark); }
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-completed{ background: var(--bg-hover); color: var(--secondary); }
.badge-inactive { background: var(--bg-hover); color: var(--text-muted); }

/* --- MODALS --- */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(44, 31, 20, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalSlideUp 0.25s ease;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-weight: 700;
    font-size: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    line-height: 1;
}

.close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

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

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

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 20px;
}

/* --- FILTERS --- */
.filters { margin-bottom: 20px; }

.filter-form,
.search-form {
    display: flex;
    gap: 10px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
    align-items: stretch;
}

.filter-form input,
.search-form input { flex: 1; min-width: 0; }

.filter-form select { min-width: 160px; flex-shrink: 0; }

.filter-form .btn,
.search-form .btn { flex-shrink: 0; }

/* --- IMAGES --- */
.image-preview { margin-top: 12px; max-width: 280px; }

.image-preview img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.image-preview small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.gallery-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.order-image {
    max-width: 100%;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
}

.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    font-size: 36px;
    color: white;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    transition: var(--transition);
}

.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* Responsive */
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .filter-form,
    .search-form { flex-direction: column; }
    .filter-form select { min-width: 100%; }
    .modal-content { padding: 24px; }
    .btn { font-size: 13px; padding: 9px 16px; }
    .data-table th,
    .data-table td { padding: 8px 10px; font-size: 13px; }
}