/* Modern Clean Design - Inspired by shadcn/ui */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: #ffffff;
    --foreground: #09090b;
    --card: #ffffff;
    --card-foreground: #09090b;
    --popover: #ffffff;
    --popover-foreground: #09090b;
    --primary: #0f172a;
    --primary-foreground: #f8fafc;
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --accent: #f1f5f9;
    --accent-foreground: #0f172a;
    --destructive: #ef4444;
    --destructive-foreground: #f8fafc;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #0f172a;
    --radius: 0.5rem;
    --sidebar-bg: #0f172a;
    --sidebar-foreground: #f8fafc;
    --sidebar-accent: #1e293b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--foreground);
    background: #f8fafc;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-foreground);
    padding: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    z-index: 100;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.logo {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.logo h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--sidebar-foreground);
    letter-spacing: 0.3px;
}

.sidebar nav ul {
    list-style: none;
    padding: 8px;
}

.sidebar nav ul li {
    margin: 2px 0;
}

.sidebar nav ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar nav ul li a i {
    width: 18px;
    font-size: 14px;
    text-align: center;
}

.sidebar nav ul li a:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-foreground);
}

.sidebar nav ul li a.active {
    background: var(--sidebar-accent);
    color: var(--sidebar-foreground);
    font-weight: 600;
}

.sidebar nav ul li a.logout-link {
    color: #f87171;
}

.sidebar nav ul li a.logout-link:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
}

/* Main Content */
.main-content {
    margin-left: 240px;
    padding: 24px;
    min-height: 100vh;
    background: #f8fafc;
    transition: margin-top 0.3s ease;
}

/* Adjust main content when top menu is present */
body.has-top-menu .main-content {
    margin-top: 60px;
}

/* Header */
header {
    background: var(--card);
    padding: 16px 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.3px;
}

.user-info {
    color: var(--muted-foreground);
    font-size: 12px;
}

/* Top Menu Bar - Horizontal Menu */
.top-menu-bar {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 60px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 24px;
}

.top-menu-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-menu-item {
    position: relative;
    display: inline-block;
}

.menu-trigger,
.profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--foreground);
    text-decoration: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
}

.menu-trigger:hover,
.profile-trigger:hover {
    background: var(--muted);
    border-color: var(--border);
}

.profile-trigger {
    gap: 10px;
}

.profile-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.profile-name {
    font-weight: 500;
    color: var(--foreground);
}

.menu-trigger i,
.profile-trigger i.fa-chevron-down {
    font-size: 12px;
    color: var(--muted-foreground);
    transition: transform 0.2s ease;
}

.top-menu-item.active .menu-trigger i.fa-chevron-down,
.top-menu-item.active .profile-trigger i.fa-chevron-down {
    transform: rotate(180deg);
}

.top-menu-item.active .menu-trigger,
.top-menu-item.active .profile-trigger {
    background: var(--muted);
    border-color: var(--border);
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    padding: 4px;
}

.top-menu-item.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--foreground);
    text-decoration: none;
    border-radius: calc(var(--radius) - 2px);
    transition: all 0.15s ease;
    font-size: 13px;
    font-weight: 400;
}

.dropdown-item:hover {
    background: var(--muted);
    color: var(--foreground);
}

.dropdown-item i {
    width: 16px;
    font-size: 14px;
    color: var(--muted-foreground);
    text-align: center;
}

.dropdown-item:hover i {
    color: var(--foreground);
}

.dropdown-item.logout-item {
    color: var(--destructive);
}

.dropdown-item.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--destructive);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}


/* Responsive */
@media (max-width: 768px) {
    .top-menu-bar {
        left: 0;
        padding: 0 16px;
    }
    
    .top-menu-container {
        gap: 4px;
    }
    
    .menu-trigger span,
    .profile-name {
        display: none;
    }
    
    .menu-trigger,
    .profile-trigger {
        padding: 8px 12px;
    }
    
    .dropdown-menu {
        right: 0;
        left: auto;
        min-width: 200px;
    }
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    padding: 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    margin-right: 12px;
}

.stat-info h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-info p {
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 500;
}

.dashboard-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
}

/* Card */
.card {
    background: var(--card);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.card h2 {
    margin-bottom: 16px;
    color: var(--foreground);
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

table th,
table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--muted);
    font-weight: 600;
    color: var(--foreground);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tbody tr {
    transition: background 0.15s ease;
}

table tbody tr:hover {
    background: var(--muted);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.5;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    background: #1e293b;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-info {
    background: #3b82f6;
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--foreground);
    font-weight: 500;
    font-size: 12px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--input);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--background);
    color: var(--foreground);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    overflow: auto;
}

.modal-content {
    background: var(--card);
    margin: 40px auto;
    padding: 24px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content iframe {
    border: none;
    border-radius: 4px;
    background: #fff;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    color: var(--foreground);
    font-size: 16px;
    font-weight: 600;
}

.close {
    color: var(--muted-foreground);
    font-size: 24px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.close:hover {
    color: var(--foreground);
}

/* Alert */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 6px;
    display: none;
    font-size: 12px;
    border: 1px solid;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Status Badge */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-draft {
    background: var(--muted);
    color: var(--muted-foreground);
}

.status-sent {
    background: #dbeafe;
    color: #1e40af;
}

.status-paid {
    background: #d1fae5;
    color: #065f46;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-inactive {
    background: var(--muted);
    color: var(--muted-foreground);
}

.status-blocked {
    background: #fee2e2;
    color: #991b1b;
}

.acknowledged-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    background: #d1fae5;
    color: #065f46;
    margin-right: 6px;
}

/* Items */
.items-table {
    margin-top: 16px;
}

.items-table th {
    background: var(--muted);
}

.item-row {
    background: var(--muted);
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted-foreground);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    color: var(--muted-foreground);
    opacity: 0.5;
}

.empty-state p {
    font-size: 13px;
    margin-top: 8px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 24px;
    color: var(--muted-foreground);
    font-size: 13px;
}

/* Small text helper */
small {
    font-size: 11px;
    color: var(--muted-foreground);
    display: block;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .dashboard-content {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }
}
