/* Viadux OCS Admin Panel - Styles */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    
    --accent-color: #c41e3a;
    --accent-hover: #a01829;
    
    --border-color: #dee2e6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow: hidden;
}

/* Title Bar */
.titlebar-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.titlebar-left, .titlebar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.titlebar-logo svg {
    width: 30px;
    height: 30px;
}

.titlebar-title {
    font-size: 18px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    opacity: 0.9;
}

/* Organization Selector */
.org-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    transition: var(--transition);
}

.org-selector:hover {
    background: rgba(255, 255, 255, 0.15);
}

.org-selector svg {
    flex-shrink: 0;
}

.org-select {
    background: transparent;
    border: none;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    padding: 0;
    min-width: 180px;
}

.org-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px;
}

/* Connection Banner */
.connection-banner {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    padding: 8px 24px;
    background: var(--warning);
    color: #000;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 999;
}

.connection-banner.hidden {
    display: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    padding-top: 56px;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-secondary);
    color: var(--accent-color);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-color);
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Navigation Separator */
.nav-separator {
    height: 1px;
    background: var(--border-color);
    margin: 12px 24px;
}

/* Navigation Organization Selector */
.nav-org-selector {
    padding: 8px 24px 12px;
}

.nav-org-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.nav-org-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-org-select:hover {
    border-color: var(--accent-color);
}

.nav-org-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.content-area {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header Section */
.content-header {
    margin-bottom: 24px;
}

.content-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.content-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    min-width: 250px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.1);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.card-actions {
    display: flex;
    gap: 4px;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--bg-tertiary);
}

.card-meta-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Table */
.table-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

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

thead {
    background: var(--bg-secondary);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

td {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

tr:hover {
    background: var(--bg-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

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

.btn-success:hover:not(:disabled) {
    background: #218838;
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 8px;
}

/* Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-rejected {
    background: #f8d7da;
    color: #721c24;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #e2e3e5;
    color: #383d41;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

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

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-help {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
    pointer-events: none;
    z-index: 3000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
    color: #000;
}

/* Loading */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-spinner p {
    margin-top: 16px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
}

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

/* Version/Status Footer in Sidebar */
.sidebar-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
}

.sidebar-footer .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.sidebar-footer .status-indicator.connected {
    background: var(--success);
}

.sidebar-footer .status-indicator.disconnected {
    background: var(--danger);
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .titlebar-title {
        font-size: 16px;
    }

    .sidebar {
        width: 220px;
    }

    .main-content {
        padding: 16px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .titlebar-header {
        padding: 0 12px;
    }

    .titlebar-title {
        font-size: 14px;
    }

    .titlebar-right .user-info span {
        display: none;
    }

    .titlebar-right .btn span {
        display: none;
    }

    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 1600;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .main-content {
        padding: 12px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .toolbar-left, .toolbar-right {
        flex-direction: column;
        width: 100%;
    }

    .toolbar-left .btn,
    .toolbar-right .btn {
        width: 100%;
        justify-content: center;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
        min-width: unset;
    }

    .content-title {
        font-size: 20px;
    }

    /* Table responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Modal responsive */
    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: 95vh;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 100px;
    }

    /* Card responsive */
    .card {
        padding: 16px;
    }

    .card-actions {
        flex-wrap: wrap;
    }

    /* Toast responsive */
    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
    .titlebar-header {
        height: 50px;
    }

    .dashboard-layout {
        padding-top: 50px;
    }

    .sidebar {
        top: 50px;
        width: 100%;
    }

    .content-title {
        font-size: 18px;
    }

    .btn-sm {
        padding: 8px 10px;
        font-size: 11px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
