﻿/* Reusable Components CSS with Brand Color Integration */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

    .btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.btn-primary {
    background: var(--brand-gradient);
    color: white;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
}

    .btn-primary::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
        transition: left 0.5s ease;
    }

    .btn-primary:hover::before {
        left: 100%;
    }

    .btn-primary:hover:not(:disabled) {
        background: var(--brand-primary-hover);
        border-color: var(--brand-primary-hover);
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-primary);
    border-color: var(--border-color);
}

    .btn-secondary:hover:not(:disabled) {
        background: var(--brand-gradient-subtle);
        border-color: var(--brand-primary);
        color: var(--brand-primary);
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-color: #10b981;
    box-shadow: var(--shadow-sm);
}

    .btn-success:hover:not(:disabled) {
        background: #059669;
        border-color: #059669;
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border-color: #ef4444;
    box-shadow: var(--shadow-sm);
}

    .btn-danger:hover:not(:disabled) {
        background: #dc2626;
        border-color: #dc2626;
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-color: #f59e0b;
    box-shadow: var(--shadow-sm);
}

    .btn-warning:hover:not(:disabled) {
        background: #d97706;
        border-color: #d97706;
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

    .btn-ghost:hover:not(:disabled) {
        background: var(--brand-gradient-subtle);
        color: var(--brand-primary);
        border-color: var(--brand-primary);
    }

/* Button Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 10px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

    .form-label.required::after {
        content: '*';
        color: #ef4444;
        margin-left: 4px;
    }

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: inherit;
}

    .form-input:focus {
        outline: none;
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        transform: translateY(-1px);
    }

    .form-input:disabled {
        background: var(--bg-gray-50);
        color: var(--text-secondary);
        cursor: not-allowed;
    }

    .form-input.error {
        border-color: #ef4444;
    }

        .form-input.error:focus {
            border-color: #ef4444;
            box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
        }

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-white);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

    .form-select:focus {
        outline: none;
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        transform: translateY(-1px);
    }

.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    background: var(--bg-white);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

    .form-textarea:focus {
        outline: none;
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        transform: translateY(-1px);
    }

.form-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 4px;
}

.form-help {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

    .card:hover {
        box-shadow: var(--shadow-lg);
        border-color: var(--brand-primary);
        transform: translateY(-2px);
    }

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--brand-gradient-subtle);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--brand-primary);
    margin: 0;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-gray-50);
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.alert-info {
    background: rgba(37, 99, 235, 0.1);
    color: var(--brand-secondary);
    border-left-color: var(--brand-primary);
}

[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--brand-primary-light);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #166534;
    border-left-color: #10b981;
}

[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #86efac;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-left-color: #f59e0b;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border-left-color: #ef4444;
}

[data-theme="dark"] .alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.alert-dismissible {
    position: relative;
    padding-right: 48px;
}

.alert-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: currentColor;
    opacity: 0.6;
    transition: opacity 0.2s;
    border-radius: 4px;
    padding: 4px;
}

    .alert-close:hover {
        opacity: 1;
        background: rgba(0, 0, 0, 0.1);
    }

/* Tables */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
}

    .table th {
        background: var(--brand-gradient-subtle);
        padding: 16px 20px;
        text-align: left;
        font-size: 13px;
        font-weight: 600;
        color: var(--brand-primary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-bottom: 2px solid var(--brand-primary);
    }

    .table td {
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-color);
        font-size: 14px;
        color: var(--text-primary);
    }

    .table tbody tr {
        transition: all 0.2s ease;
    }

        .table tbody tr:hover {
            background: var(--brand-gradient-subtle);
            transform: scale(1.001);
        }

        .table tbody tr:last-child td {
            border-bottom: none;
        }

/* Dark theme table adjustments */
[data-theme="dark"] .table th {
    background: rgba(59, 130, 246, 0.1);
    color: var(--brand-primary-light);
    border-bottom-color: var(--brand-primary-light);
}

[data-theme="dark"] .table tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.badge-primary {
    background: var(--brand-gradient-subtle);
    color: var(--brand-primary);
    border-color: rgba(37, 99, 235, 0.2);
}

[data-theme="dark"] .badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: var(--brand-primary-light);
    border-color: rgba(59, 130, 246, 0.3);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.2);
}

[data-theme="dark"] .badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

.badge-secondary {
    background: var(--bg-gray-100);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

    .loading-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--brand-primary);
        animation: bounce 1.4s ease-in-out infinite both;
    }

        .loading-dots span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .loading-dots span:nth-child(2) {
            animation-delay: -0.16s;
        }

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
}

    .pagination .btn {
        min-width: 40px;
        height: 40px;
        border-radius: 8px;
        font-weight: 500;
    }

        .pagination .btn.active {
            background: var(--brand-gradient);
            color: white;
            border-color: var(--brand-primary);
        }

.pagination-info {
    margin: 0 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Filters */
.filters-bar {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.filter-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Modal/Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

    .modal-overlay.show {
        opacity: 1;
        visibility: visible;
    }

.modal {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--brand-gradient-subtle);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--brand-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 6px;
}

    .modal-close:hover {
        color: var(--text-primary);
        background: var(--bg-gray-50);
        transform: scale(1.1);
    }

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-gray-50);
}

/* Code/Pre blocks */
.code-block {
    background: var(--bg-gray-50);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre;
    border-left: 4px solid var(--brand-primary);
}

[data-theme="dark"] .code-block {
    background: var(--brand-gray-800);
    border-color: var(--brand-gray-700);
}

/* Responsive Utilities */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Log Entries */
.log-entry {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    transition: all 0.2s ease;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 2px;
}

    .log-entry:hover {
        background: var(--brand-gradient-subtle);
        transform: translateX(4px);
        box-shadow: var(--shadow-sm);
    }

    .log-entry:last-child {
        border-bottom: none;
    }

.log-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.log-info {
    flex: 1;
}

.log-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.log-operation {
    font-size: 13px;
    color: var(--text-secondary);
}

.log-level {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.level-info {
    background: rgba(37, 99, 235, 0.1);
    color: var(--brand-primary);
    border-color: rgba(37, 99, 235, 0.2);
}

.level-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.2);
}

.level-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.2);
}

.level-critical {
    background: rgba(190, 24, 93, 0.1);
    color: #be185d;
    border-color: rgba(190, 24, 93, 0.2);
}

.log-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.log-timestamp {
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--brand-primary);
    font-weight: 500;
}

.log-message {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-gray-50);
    border-radius: 8px;
    border-left: 3px solid var(--brand-primary);
    font-size: 13px;
    font-family: 'SF Mono', Monaco, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Dark theme adjustments for log levels */
[data-theme="dark"] .level-info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--brand-primary-light);
    border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .level-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .level-error {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .level-critical {
    background: rgba(190, 24, 93, 0.2);
    color: #f9a8d4;
    border-color: rgba(190, 24, 93, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: stretch;
    }

        .filter-actions .btn {
            flex: 1;
        }

    .modal {
        margin: 20px;
        width: calc(100% - 40px);
    }

    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }

    .pagination-info {
        order: -1;
        width: 100%;
        text-align: center;
        margin: 0 0 16px 0;
    }

    .table-container {
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 12px 16px;
    }

    .log-main {
        flex-direction: column;
        gap: 8px;
    }

    .log-meta {
        flex-direction: column;
        gap: 4px;
    }
}

/* Enhanced Interactive Elements */
.btn:active {
    transform: translateY(0) scale(0.98);
}

.card:active {
    transform: translateY(0) scale(0.995);
}

/* Focus styles for accessibility */
.btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* Progress bars */
.progress {
    width: 100%;
    height: 8px;
    background: var(--bg-gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--brand-gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

    .tooltip::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: var(--brand-gray-800);
        color: white;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 12px;
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
        margin-bottom: 8px;
        box-shadow: var(--shadow-md);
    }

    .tooltip:hover::after {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(-4px);
    }
