/* ========= BUTTONS ========= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.95rem;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-accent { background: var(--accent); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--border-light); }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: var(--border-light); }

.btn-lg {
    padding: 16px 32px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 12px;
}

.btn-icon {
    width: 40px; height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ========= INPUTS ========= */

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--text-light);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    transition: border-color 0.15s;
    font-size: 0.95rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input {
    padding: 12px 16px;
    font-size: 1.05rem;
    border-radius: var(--radius);
}

/* ========= CARDS ========= */

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

/* ========= HEADER ========= */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--primary);
    color: white;
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow-lg);
}

.app-header h1 {
    font-size: 1.2rem;
    margin-right: 32px;
    white-space: nowrap;
}

.app-header .header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-tab {
    padding: 8px 18px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.15s;
    border: none;
    background: none;
    font-size: 0.95rem;
}
.nav-tab:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-tab.active { color: white; background: rgba(255,255,255,0.2); }

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

/* ========= TABLES ========= */

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

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

.data-table th {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg);
}

.data-table tr:hover td {
    background: var(--primary-light);
}

/* ========= MODALS ========= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 680px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 { font-size: 1.2rem; }

.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: var(--border-light);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ========= TOAST ========= */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    min-width: 260px;
    box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }

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

/* ========= FORMAT TILES ========= */

.format-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.format-tile {
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
}
.format-tile:hover { border-color: var(--primary); }
.format-tile.active {
    border-color: var(--primary);
    background: var(--primary-light);
}
.format-tile .tile-icon {
    font-size: 2rem;
    margin-bottom: 6px;
}
.format-tile .tile-label {
    font-weight: 700;
    font-size: 0.95rem;
}
.format-tile .tile-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========= COPIES ========= */

.copies-control {
    display: flex;
    align-items: center;
    gap: 12px;
}
.copies-control .btn-copies {
    width: 48px; height: 48px;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--border);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.copies-control .btn-copies:hover { border-color: var(--primary); }
.copies-control input {
    width: 80px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 8px;
}

/* ========= BADGE ========= */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-admin { background: var(--primary-light); color: var(--primary); }
.badge-user { background: var(--accent-light); color: var(--accent-dark); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--error-bg); color: var(--error); }

/* ========= RESPONSIVE ========= */

@media (max-width: 768px) {
    .app-header {
        padding: 0 12px;
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-h);
    }
    .app-header nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding: 4px 0;
    }
    .nav-tab { font-size: 0.85rem; padding: 6px 12px; }
    .modal { max-width: 95%; padding: 16px; }
    .format-tiles { grid-template-columns: repeat(2, 1fr); }
}
