/* ===========================================
   Fakturklient.cz - Main Stylesheet
   =========================================== */

/* CSS Variables */
:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #3b82f6;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-gray-900);
    background-color: var(--color-gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-gray-900);
}

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

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

a:hover {
    text-decoration: underline;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.hidden { display: none !important; }

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-gray-200);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-gray-200);
    background: var(--color-gray-50);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-gray-700);
    margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-gray-900);
    background-color: white;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

.form-input::placeholder {
    color: var(--color-gray-400);
}

.form-input.is-invalid {
    border-color: var(--color-danger);
}

.form-error {
    font-size: 0.75rem;
    color: var(--color-danger);
    margin-top: 0.25rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--color-gray-500);
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    transition: all 0.15s;
}

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

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

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

.btn-secondary {
    color: var(--color-gray-700);
    background-color: white;
    border-color: var(--color-gray-300);
}

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

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

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
}

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

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-gray-200);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
    background: var(--color-gray-50);
}

.table tbody tr:hover {
    background: var(--color-gray-50);
}

.table-responsive {
    overflow-x: auto;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    color: var(--color-primary-dark);
    background: rgb(37 99 235 / 0.1);
}

.badge-success {
    color: #065f46;
    background: rgb(16 185 129 / 0.1);
}

.badge-warning {
    color: #92400e;
    background: rgb(245 158 11 / 0.1);
}

.badge-danger {
    color: #991b1b;
    background: rgb(239 68 68 / 0.1);
}

.badge-gray {
    color: var(--color-gray-700);
    background: var(--color-gray-100);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.alert-warning {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.alert-info {
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

/* Navigation */
.navbar {
    background: white;
    border-bottom: 1px solid var(--color-gray-200);
    padding: 0 1rem;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--color-gray-600);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.nav-link:hover {
    color: var(--color-gray-900);
    background: var(--color-gray-100);
    text-decoration: none;
}

.nav-link.active {
    color: var(--color-primary);
    background: rgb(37 99 235 / 0.1);
}

/* Sidebar Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: white;
    border-right: 1px solid var(--color-gray-200);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--color-gray-200);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-gray-200);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-header {
    background: white;
    border-bottom: 1px solid var(--color-gray-200);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.main-header h1 {
    flex: 1;
}

/* Quick Add Button & Menu */
.quick-add-wrapper {
    position: relative;
}

.quick-add-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: #22c55e;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, transform 0.1s;
    box-shadow: var(--shadow);
}

.quick-add-btn:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.quick-add-btn:active {
    transform: scale(0.98);
}

.quick-add-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: #fef9c3;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    z-index: 1000;
    padding: 0.5rem 0;
}

.quick-add-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.quick-add-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--color-gray-800);
    text-decoration: none;
    transition: background-color 0.15s;
}

.quick-add-item:hover {
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
}

.quick-add-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-600);
}

.quick-add-label {
    font-size: 0.9375rem;
    font-weight: 500;
}

.quick-add-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0.5rem 0;
}

.main-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Auth Layout */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 1.75rem;
    color: var(--color-primary);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Loading */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgb(255 255 255 / 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Notifications */
.notifications {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: white;
    border-left: 4px solid var(--color-primary);
    animation: slideIn 0.3s ease;
}

.notification.success { border-left-color: var(--color-success); }
.notification.error { border-left-color: var(--color-danger); }
.notification.warning { border-left-color: var(--color-warning); }

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

/* Company Lookup Component */
.company-lookup {
    text-align: center;
    padding: 1rem 0;
}

.lookup-title {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-gray-700);
    margin-bottom: 1.25rem;
}

.lookup-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto 0.75rem;
    position: relative;
}

.lookup-input {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--color-gray-200);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.lookup-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.lookup-input::placeholder {
    color: var(--color-gray-400);
}

.country-switcher {
    display: flex;
    gap: 0.5rem;
}

.country-btn {
    width: 44px;
    height: 44px;
    padding: 6px;
    background: white;
    border: 2px solid var(--color-gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.country-btn:hover {
    border-color: var(--color-gray-300);
    transform: translateY(-1px);
}

.country-btn.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.country-flag {
    width: 28px;
    height: 20px;
    border-radius: 2px;
    overflow: hidden;
}

.lookup-loading {
    position: absolute;
    right: 160px;
    top: 50%;
    transform: translateY(-50%);
}

.lookup-hint {
    font-size: 0.875rem;
    color: var(--color-gray-500);
    margin-top: 0.5rem;
}

.lookup-hint strong {
    color: var(--color-gray-700);
}

/* Search Results */
.search-results {
    max-width: 600px;
    margin: 1rem auto 0;
    text-align: left;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    background: white;
    box-shadow: var(--shadow-md);
}

.search-result-item {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-gray-100);
    cursor: pointer;
    transition: background-color 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--color-gray-50);
}

.result-name {
    font-weight: 500;
    color: var(--color-gray-900);
    margin-bottom: 0.25rem;
}

.result-details {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--color-gray-500);
}

.result-details span {
    display: flex;
    align-items: center;
}

/* Margin utilities */
.mb-4 { margin-bottom: 1rem; }

/* Responsive Company Lookup */
@media (max-width: 640px) {
    .lookup-input-wrapper {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .lookup-input {
        width: 100%;
    }
    
    .country-switcher {
        justify-content: center;
    }
    
    .lookup-loading {
        position: static;
        transform: none;
        margin-top: 0.5rem;
    }
    
    .result-details {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-gray-500); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.w-full { width: 100%; }

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-gray-700);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive */
@media (max-width: 1024px) {
    /* Sidebar */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s ease;
        width: 280px;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .main-header {
        padding: 1rem;
    }
    
    .main-body {
        padding: 1rem;
    }
    
    /* Quick Add - mobile adjustments */
    .quick-add-btn {
        width: 36px;
        height: 36px;
    }
    
    .quick-add-menu {
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    /* Typography */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    
    /* Cards */
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    /* Grids - stack on mobile */
    .grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    
    .grid [style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }
    
    /* Tables */
    .table th,
    .table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    /* Hide some columns on mobile */
    .table .hide-mobile {
        display: none;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 0.875rem;
    }
    
    .flex.justify-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .flex.gap-2 {
        flex-wrap: wrap;
    }
    
    /* Invoice form items - stack */
    .item-row[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
        padding: 1rem;
        background: var(--color-gray-50);
        border-radius: var(--radius);
        margin-bottom: 0.75rem;
    }
    
    .item-row .form-group {
        margin-bottom: 0;
    }
    
    .item-row .form-label {
        display: block !important;
    }
    
    /* Dashboard cards */
    .grid.gap-6[style*="minmax(250px"] {
        grid-template-columns: 1fr 1fr !important;
    }
    
    /* Auth layout */
    .auth-card {
        max-width: 100%;
    }
    
    .auth-logo h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    html {
        font-size: 14px;
    }
    
    .main-header h1 {
        font-size: 1.25rem;
    }
    
    /* Dashboard cards - single column */
    .grid.gap-6[style*="minmax(250px"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Table - minimal padding */
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
    
    /* Buttons - full width in flex containers */
    .flex.gap-2 .btn {
        flex: 1;
        justify-content: center;
    }
    
    /* Filter buttons - scrollable */
    .flex.gap-2:has(.btn-sm) {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .flex.gap-2:has(.btn-sm) .btn {
        flex: none;
    }
}

/* ===========================================
   Invoice Form Styles
   =========================================== */

.invoice-form-page {
    max-width: 900px;
    margin: 0 auto;
}

/* Header s záložkami */
.invoice-form-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.invoice-form-title h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin: 0;
}

.invoice-form-tabs {
    display: flex;
    gap: 0.25rem;
    background: white;
    padding: 0.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-gray-200);
}

.tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-gray-600);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover {
    color: var(--color-gray-900);
    background: var(--color-gray-50);
}

.tab-btn.active {
    color: var(--color-gray-900);
    background: white;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-gray-200);
}

/* Hlavní karta formuláře */
.invoice-form-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem 2rem;
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Přidat štítek */
.add-tag-row {
    margin-bottom: 1.5rem;
}

.btn-add-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #22c55e;
    background: transparent;
    border: 1px dashed #22c55e;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-add-tag:hover {
    background: rgba(34, 197, 94, 0.05);
}

/* Form rows */
.form-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-gray-100);
}

.form-row:last-child {
    border-bottom: none;
}

.form-row-label {
    width: 180px;
    flex-shrink: 0;
    font-size: 0.875rem;
    color: var(--color-gray-600);
    text-align: right;
    padding-right: 1.5rem;
}

.form-row-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-row-content-full {
    flex-direction: column;
    align-items: stretch;
}

.form-row-content-full .form-input {
    width: 100%;
}

/* Form inputs */
.form-select-lg {
    min-width: 200px;
    max-width: 300px;
}

.form-select-sm,
.form-input-sm {
    width: auto;
    min-width: 100px;
    max-width: 150px;
}

.form-input-date {
    width: auto;
    min-width: 140px;
}

/* Invoice number display */
.invoice-number {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-gray-900);
}

/* Link buttons */
.btn-link {
    padding: 0;
    font-size: 0.8125rem;
    color: var(--color-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--color-primary-dark);
}

.btn-link-green {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #22c55e;
    text-decoration: none;
}

.btn-link-green:hover {
    color: #16a34a;
    text-decoration: none;
}

/* Help icon */
.help-icon {
    display: inline-flex;
    color: var(--color-gray-400);
    cursor: help;
}

.help-icon:hover {
    color: var(--color-gray-600);
}

/* Toggle buttons */
.toggle-buttons {
    display: inline-flex;
    gap: 0;
    background: var(--color-gray-100);
    border-radius: var(--radius);
    padding: 0.125rem;
}

.toggle-btn {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-gray-600);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: all 0.15s;
}

.toggle-btn:hover {
    color: var(--color-gray-800);
}

.toggle-btn.active {
    color: var(--color-gray-900);
    background: white;
    box-shadow: var(--shadow-sm);
}

/* Due date preview */
.due-date-preview {
    font-size: 0.8125rem;
    color: var(--color-gray-500);
}

/* Switch toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-gray-300);
    transition: 0.2s;
    border-radius: 24px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.switch input:checked + .switch-slider {
    background-color: #22c55e;
}

.switch input:checked + .switch-slider:before {
    transform: translateX(20px);
}

/* Expandable section */
.expandable-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-gray-200);
}

.expandable-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #22c55e;
    background: transparent;
    border: 1px solid #22c55e;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0 auto;
    display: flex;
}

.expandable-toggle:hover {
    background: rgba(34, 197, 94, 0.05);
}

.expandable-content {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-gray-100);
}

/* Items card */
.invoice-items-card {
    background: white;
    border-left: 1px solid var(--color-gray-200);
    border-right: 1px solid var(--color-gray-200);
    padding: 1.5rem 2rem;
}

.items-header {
    display: flex;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-gray-200);
    margin-bottom: 0.5rem;
}

.items-header .item-col {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
}

.item-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    gap: 0.5rem;
}

.item-col {
    flex-shrink: 0;
}

.item-col-handle {
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drag-handle {
    cursor: grab;
    color: var(--color-gray-400);
}

.drag-handle:hover {
    color: var(--color-gray-600);
}

.item-col-quantity {
    width: 70px;
}

.item-col-unit {
    width: 60px;
}

.item-col-description {
    flex: 1;
    min-width: 200px;
}

.item-col-price {
    width: 120px;
}

.item-col-vat {
    width: 60px;
}

.item-col-action {
    width: 32px;
    display: flex;
    justify-content: center;
}

.item-row .form-input {
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
}

.btn-remove-item {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--color-gray-400);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-remove-item:hover {
    color: var(--color-danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Items actions */
.items-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-gray-100);
}

.btn-add-item,
.btn-add-discount {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #22c55e;
    background: transparent;
    border: 1px solid #22c55e;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-add-item:hover,
.btn-add-discount:hover {
    background: rgba(34, 197, 94, 0.05);
}

.btn-add-discount {
    color: var(--color-gray-500);
    border-color: var(--color-gray-300);
}

.btn-add-discount:hover {
    color: var(--color-gray-700);
    background: var(--color-gray-50);
}

.items-vat-mode {
    margin-left: auto;
    font-size: 0.8125rem;
    color: var(--color-gray-500);
}

.vat-mode-link {
    color: #22c55e;
    font-weight: 500;
}

/* Summary card */
.invoice-summary-card {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-top: none;
    padding: 1.5rem 2rem;
}

.summary-table {
    max-width: 400px;
    margin-left: auto;
}

.summary-header {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    gap: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-gray-200);
    margin-bottom: 0.5rem;
}

.summary-header span {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
    text-align: right;
}

.summary-header span:first-child {
    text-align: left;
}

.summary-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    gap: 1rem;
    padding: 0.375rem 0;
    border-bottom: 2px solid #eab308;
}

.summary-rate {
    font-size: 0.875rem;
    color: var(--color-gray-700);
}

.summary-base,
.summary-vat {
    font-size: 0.875rem;
    color: var(--color-gray-900);
    text-align: right;
}

.summary-total {
    text-align: right;
    margin-top: 1rem;
    padding-top: 0.5rem;
}

.summary-total span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-gray-900);
}

/* Actions card */
.invoice-actions-card {
    background: white;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border: 1px solid var(--color-gray-200);
    border-top: none;
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.btn-action-link {
    padding: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-gray-600);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.btn-action-link:hover {
    color: var(--color-gray-900);
}

/* Button group */
.btn-group {
    display: inline-flex;
    position: relative;
}

.btn-group .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-group .btn-dropdown {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem 0.625rem;
}

.btn.btn-primary {
    background-color: #eab308;
    border-color: #eab308;
    color: var(--color-gray-900);
}

.btn.btn-primary:hover:not(:disabled) {
    background-color: #ca8a04;
    border-color: #ca8a04;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Action dropdown */
.action-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    min-width: 200px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-gray-200);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.15s;
    z-index: 100;
}

.action-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--color-gray-700);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background: var(--color-gray-50);
}

.dropdown-item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Checkbox label */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-gray-600);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #22c55e;
}

/* Info box */
.info-box {
    display: flex;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
    background: #fef9c3;
    border-radius: var(--radius-lg);
    border: 1px solid #fde68a;
}

.info-box-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 197, 94, 0.1);
    border-radius: var(--radius);
    color: #22c55e;
}

.info-box-content {
    flex: 1;
}

.info-box-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin-bottom: 0.5rem;
}

.info-box-content p {
    font-size: 0.875rem;
    color: var(--color-gray-700);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.info-box-content ul {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
}

.info-box-content li {
    font-size: 0.875rem;
    color: var(--color-gray-700);
    margin-bottom: 0.25rem;
}

.info-box-content code {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8125rem;
    color: #b45309;
    background: rgba(180, 83, 9, 0.1);
    border-radius: 4px;
}

.info-box-content code.highlight {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

/* Close button for info box */
.info-box-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-400);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
}

.info-box-close:hover {
    color: var(--color-gray-600);
    background: rgba(0, 0, 0, 0.05);
}

/* Responsive invoice form */
@media (max-width: 768px) {
    .invoice-form-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .invoice-form-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .form-row-label {
        width: 100%;
        text-align: left;
        padding-right: 0;
        padding-bottom: 0.25rem;
    }
    
    .form-row-content {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .form-select-lg {
        max-width: 100%;
        width: 100%;
    }
    
    .invoice-form-card,
    .invoice-items-card,
    .invoice-summary-card,
    .invoice-actions-card {
        padding: 1rem;
    }
    
    .items-header {
        display: none;
    }
    
    .item-row {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 1rem;
        background: var(--color-gray-50);
        border-radius: var(--radius);
        margin-bottom: 0.5rem;
    }
    
    .item-col-handle {
        display: none;
    }
    
    .item-col-quantity,
    .item-col-unit,
    .item-col-vat {
        width: calc(33.33% - 0.5rem);
    }
    
    .item-col-description,
    .item-col-price {
        width: 100%;
    }
    
    .item-col-action {
        position: absolute;
        right: 0.5rem;
        top: 0.5rem;
    }
    
    .item-row {
        position: relative;
    }
    
    .items-actions {
        flex-wrap: wrap;
    }
    
    .items-vat-mode {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .invoice-actions-card {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
}
