/**
 * WiseLogic App - Main Stylesheet
 * Professional, clean, modern design
 */

:root {
    /* Colors */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #0f172a;
    --gray-900: #0f172a;
    --gray-800: #1e293b;
    --gray-700: #334155;
    --gray-600: #475569;
    --gray-500: #64748b;
    --gray-400: #94a3b8;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    --gray-50: #f8fafc;
    --white: #ffffff;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition: all 0.2s ease;
}

/* Dark theme variables */
[data-theme="dark"] {
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

/* Light theme variables */
[data-theme="light"] {
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
}

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

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-900);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-full {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--secondary); }

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }

/* Alerts */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    font-weight: 500;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-info {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .card {
        padding: var(--spacing-lg);
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
}


/* ============================================
   INVOICES TABLE - Dark/Light Mode Compatible
   ============================================ */

/* Invoice row states - Light mode */
[data-theme="light"] .invoice-overdue {
    background-color: #fff5f5 !important;
    border-left: 3px solid #dc3545;
}

[data-theme="light"] .invoice-overdue:hover {
    background-color: #ffe5e5 !important;
}

[data-theme="light"] .invoice-due-today {
    background-color: #fffbf0 !important;
    border-left: 3px solid #ffc107;
}

[data-theme="light"] .invoice-due-today:hover {
    background-color: #fff3d9 !important;
}

[data-theme="light"] .invoice-due-soon {
    background-color: #fffef7 !important;
    border-left: 3px solid #ffc107;
    border-left-style: dashed;
}

[data-theme="light"] .invoice-due-soon:hover {
    background-color: #fffaeb !important;
}

/* Invoice row states - Dark mode */
[data-theme="dark"] .invoice-overdue {
    background-color: #3d1a1a !important;
    border-left: 3px solid #ff6b6b;
}

[data-theme="dark"] .invoice-overdue:hover {
    background-color: #4a2020 !important;
}

[data-theme="dark"] .invoice-due-today {
    background-color: #3d3419 !important;
    border-left: 3px solid #ffd93d;
}

[data-theme="dark"] .invoice-due-today:hover {
    background-color: #4a3f1f !important;
}

[data-theme="dark"] .invoice-due-soon {
    background-color: #3d3a19 !important;
    border-left: 3px solid #ffd93d;
    border-left-style: dashed;
}

[data-theme="dark"] .invoice-due-soon:hover {
    background-color: #4a451f !important;
}

/* Actions column - buttons in row */
#received-invoices-table td:last-child {
    white-space: nowrap;
}

#received-invoices-table .btn-icon {
    padding: 0.35rem 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
    margin-right: 0.25rem;
    border: none;
    background: transparent;
    cursor: pointer;
}

#received-invoices-table .btn-icon:last-child {
    margin-right: 0;
}

#received-invoices-table .btn-icon:hover {
    transform: scale(1.05);
}

[data-theme="light"] .btn-icon:hover {
    background-color: #f1f5f9;
}

[data-theme="dark"] .btn-icon:hover {
    background-color: #334155;
}

#received-invoices-table .btn-icon.btn-success {
    color: #28a745;
}

#received-invoices-table .btn-icon.btn-success:hover {
    background-color: #28a745;
    color: white;
}

/* Reduce row height */
#received-invoices-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

#received-invoices-table td small {
    display: block;
    font-size: 0.7rem;
    margin-top: 0.15rem;
    line-height: 1.2;
}

#received-invoices-table td .fw-medium {
    line-height: 1.3;
}

/* Badge count inline with button */
#received-invoices-table .badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
}

#received-invoices-table .btn-icon {
    position: relative;
}

/* Typography - inherit colors from theme */
.fw-medium {
    font-weight: 500;
}

.text-nowrap {
    white-space: nowrap;
}

.text-end {
    text-align: right;
}

/* Remove conflicting styles */
#received-invoices-table tbody tr {
    transition: background-color 0.15s ease-in-out;
}


/* ============================================
   COMPACT LAYOUT - Full Height Table
   ============================================ */

/* Override app-content to remove padding and enable flex layout */
#app-content {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Compact header - single line, no wrap */
.page-header-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    margin: 0.5rem 0.5rem 0 0.5rem;
    gap: 1rem;
    flex-shrink: 0;
    background: var(--background);
}

.page-header-compact .header-left h1 {
    font-size: 1.5rem;
    margin: 0;
    white-space: nowrap;
}

.page-header-compact .header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Compact form controls - all inline */
.search-input-compact {
    width: 180px;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    transition: var(--transition);
}

.search-input-compact:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.select-compact {
    padding: 0.4rem 1.75rem 0.4rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    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='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.select-compact:focus {
    outline: none;
    border-color: var(--primary);
}

/* Full height table container */
.invoices-table-fullheight {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    margin: 0 0.5rem 0.5rem 0.5rem;
}

.invoices-table-fullheight .table-responsive {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

/* Pagination at bottom */
.invoices-table-fullheight .pagination-container {
    flex-shrink: 0;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: var(--background);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Table styling - compact rows */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
}

.data-table thead th {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    background: var(--surface);
}

.data-table tbody td {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle !important;
}

/* Action buttons - horizontal only */
.actions-cell {
    white-space: nowrap !important;
}

.actions-cell .btn-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.3rem !important;
    margin-right: 0.25rem !important;
    vertical-align: middle !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer !important;
    border-radius: 0.25rem !important;
    transition: all 0.15s ease-in-out !important;
}

.actions-cell .btn-icon:last-child {
    margin-right: 0 !important;
}

.actions-cell .btn-icon:hover {
    background-color: var(--surface-hover) !important;
    transform: scale(1.05) !important;
}

.actions-cell .btn-icon svg {
    width: 14px !important;
    height: 14px !important;
}

/* Loading spinner positioning */
.invoices-table-fullheight .loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Empty state positioning */
.invoices-table-fullheight .empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .page-header-compact {
        flex-wrap: wrap;
        padding: 0.5rem;
    }

    .search-input-compact {
        width: 150px;
    }
}

