/* /static/css/app.css */
/* Shared application stylesheet */

/* ── Notification bell shake animation ───────────────────────────────── */
@keyframes bell-shake {
    0%, 100% { transform: rotate(0deg); }
    10%       { transform: rotate(14deg); }
    20%       { transform: rotate(-12deg); }
    30%       { transform: rotate(10deg); }
    40%       { transform: rotate(-8deg); }
    50%       { transform: rotate(6deg); }
    60%       { transform: rotate(-4deg); }
    70%       { transform: rotate(2deg); }
    80%       { transform: rotate(-2deg); }
}
.animate-bell {
    animation: bell-shake 1.2s ease-in-out;
    transform-origin: top center;
}
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
   UTILITIES
   ======================================== */

/* Alpine.js cloak utility */
[x-cloak] {
    display: none !important;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Line clamp utilities */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ========================================
   HTMX INDICATORS
   ======================================== */

.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}


/* ========================================
   PAGE LAYOUT
   ======================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1f2937;
}

.page-subtitle {
    color: #4b5563;
    margin-top: 0.25rem;
}


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

.btn-primary {
    background-color: #1e3a8a;
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
}

.btn-primary:hover {
    background-color: #1e40af;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    color: #374151;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
}

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

.btn-edit {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    color: #1d4ed8;
    background-color: #dbeafe;
    transition: background-color 0.2s;
}

.btn-edit:hover {
    background-color: #bfdbfe;
}

.btn-delete {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    color: #b91c1c;
    background-color: #fee2e2;
    transition: background-color 0.2s;
}

.btn-delete:hover {
    background-color: #fecaca;
}

.btn-icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.5rem;
}

.btn-icon-sm {
    width: 1rem;
    height: 1rem;
    margin-right: 0.25rem;
}


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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.stat-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

.stat-icon-container {
    flex-shrink: 0;
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.stat-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
}


/* ========================================
   CONTROLS & FILTERS
   ======================================== */

.controls-container {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
}

.control-select {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    outline: none;
}

.control-select:focus {
    outline: 2px solid #1e3a8a;
    outline-offset: 2px;
}


/* ========================================
   TABLE
   ======================================== */

.table-container {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

.data-table thead {
    background-color: #f9fafb;
}

.table-body {
    background-color: white;
}

.table-body tr {
    border-top: 1px solid #e5e7eb;
}

/* Table Headers */
.table-header {
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-header.sortable {
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}

.table-header.sortable:hover {
    background-color: #f3f4f6;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Sort Icons */
.sort-icons {
    display: flex;
    flex-direction: column;
}

.sort-icon-up,
.sort-icon-down {
    width: 0.75rem;
    height: 0.75rem;
    transition: opacity 0.2s;
}

.sort-icon-down {
    margin-top: -0.25rem;
}

.sort-active {
    opacity: 1;
    color: #1e3a8a;
}

.sort-inactive {
    opacity: 0.3;
}

.table-header.sortable:hover .sort-inactive {
    opacity: 0.6;
}

/* Search Row */
.search-row {
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.search-cell {
    padding: 0.5rem 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    outline: none;
}

.search-input:focus {
    outline: 1px solid #1e3a8a;
}

/* Table Rows */
.table-row {
    transition: background-color 0.2s;
}

.table-row:hover {
    background-color: #f9fafb;
}

.add-row {
    background-color: #eff6ff;
    border: 2px solid #bfdbfe;
}

.edit-row {
    background-color: #fefce8;
}


/* ========================================
   TABLE CELLS & CONTENT
   ======================================== */

.cell-code {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    width: 8%;
}

.cell-name {
    padding: 1rem 1.5rem;
    width: 12%;
}

.cell-description {
    padding: 1rem 1.5rem;
    width: 15%;
}

.cell-cost-type {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    width: 10%;
}

.cell-department {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    width: 10%;
}

.cell-manager {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    width: 12%;
}

.cell-budget {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    width: 10%;
}

.cell-status {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    width: 10%;
}

.cell-actions {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
    width: 13%;
}

/* Code Badge */
.code-badge {
    flex-shrink: 0;
    height: 2.5rem;
    width: 2.5rem;
    border-radius: 9999px;
    background: linear-gradient(to bottom right, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

.code-text {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e3a8a;
}

/* Name Display */
.name-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
}

.description-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Cost Type Display */
.cost-type-container {
    display: flex;
    align-items: center;
}

.cost-type-icon {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    color: #a855f7;
}

.cost-type-text {
    font-size: 0.875rem;
    color: #111827;
}

/* Department Display */
.department-container {
    display: flex;
    align-items: center;
}

.department-icon {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    color: #f97316;
}

.department-text {
    font-size: 0.875rem;
    color: #111827;
}

/* Manager Display */
.manager-avatar {
    flex-shrink: 0;
    height: 2rem;
    width: 2rem;
    border-radius: 9999px;
    background-color: #f3e8ff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7c3aed;
    font-weight: 600;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

.manager-text {
    font-size: 0.875rem;
    color: #111827;
}

/* Budget Display */
.budget-icon {
    width: 1rem;
    height: 1rem;
    margin-right: 0.25rem;
    color: #10b981;
}

.budget-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
}

/* Empty State */
.empty-state {
    font-size: 0.75rem;
    color: #9ca3af;
    font-style: italic;
}

/* Status Toggle */
.status-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

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

.toggle-slider {
    width: 2.75rem;
    height: 1.5rem;
    background-color: #e5e7eb;
    border-radius: 9999px;
    position: relative;
    transition: background-color 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    height: 1.25rem;
    width: 1.25rem;
    transition: transform 0.2s;
}

.toggle-input:checked + .toggle-slider {
    background-color: #1e3a8a;
}

.toggle-input:checked + .toggle-slider::after {
    transform: translateX(1.25rem);
    border-color: white;
}

.toggle-input:focus + .toggle-slider {
    outline: 4px solid #bfdbfe;
}

.toggle-label {
    margin-left: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.toggle-label.active {
    color: #16a34a;
}

.toggle-label.inactive {
    color: #dc2626;
}


/* ========================================
   FORMS
   ======================================== */

.form-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-container-lg {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
}

.form-input:focus {
    outline: 2px solid #1e3a8a;
    outline-offset: 0;
}

.form-input.uppercase {
    text-transform: uppercase;
}

.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
}

.form-textarea:focus {
    outline: 2px solid #1e3a8a;
    outline-offset: 0;
}

.form-checkbox {
    height: 1rem;
    width: 1rem;
    color: #1e3a8a;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
}

.form-checkbox:focus {
    outline: 2px solid #1e3a8a;
    outline-offset: 2px;
}

.form-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.form-checkbox-text {
    margin-left: 0.5rem;
    font-size: 0.875rem;
    color: #374151;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.form-cancel-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    color: #374151;
    background-color: white;
    transition: background-color 0.2s;
}

.form-cancel-btn:hover {
    background-color: #f9fafb;
}

.form-cancel-btn:disabled {
    opacity: 0.5;
}

.form-submit-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: white;
    background-color: #1e3a8a;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
}

.form-submit-btn:hover {
    background-color: #1e40af;
}

.form-submit-btn:disabled {
    opacity: 0.5;
}

.form-required {
    color: #ef4444;
}


/* ========================================
   AUTOCOMPLETE / DROPDOWN
   ======================================== */

.autocomplete-container {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    z-index: 10;
    width: 100%;
    margin-top: 0.25rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-height: 15rem;
    overflow: auto;
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.autocomplete-item:hover {
    background-color: #eff6ff;
}

.autocomplete-item-name {
    font-weight: 500;
}

.autocomplete-item-email {
    font-size: 0.75rem;
    color: #6b7280;
}


/* ========================================
   PAGINATION
   ======================================== */

.pagination-container {
    padding: 1rem 1.5rem;
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.pagination-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pagination-text {
    font-size: 0.875rem;
    color: #374151;
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

.pagination-btn {
    padding: 0.25rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.pagination-btn:hover {
    background-color: #e5e7eb;
}

.pagination-current {
    padding: 0.25rem 0.75rem;
    background-color: #1e3a8a;
    color: white;
    border: 1px solid #1e3a8a;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}


/* ========================================
   LOADING STATES
   ======================================== */

.spinner {
    animation: spin 1s linear infinite;
    height: 1rem;
    width: 1rem;
    margin-right: 0.5rem;
}

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

.spinner circle {
    opacity: 0.25;
}

.spinner path {
    opacity: 0.75;
}

#create-spinner.htmx-request {
    display: inline-block !important;
}


/* ========================================
   NOTIFICATIONS
   ======================================== */

.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background-color: #10b981;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

.notification.error {
    background-color: #ef4444;
}

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