/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #22c55e;
    --success-light: #dcfce7;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --error-color: #ef4444;
    --error-light: #fee2e2;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);
    --transition: all 0.2s ease;
}

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.toolbar-left, .toolbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn .icon {
    font-size: 1rem;
}

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

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

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

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

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-text {
    background: none;
    color: var(--primary-color);
    padding: 0.5rem;
}

.btn-text:hover {
    background-color: var(--primary-light);
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

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

.btn-icon {
    padding: 0.5rem;
    min-width: 36px;
    justify-content: center;
}

/* Search and Filter */
.search-filter {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    background-color: white;
    cursor: pointer;
    min-width: 150px;
}

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

/* Variables Container */
.variables-container {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    min-height: 300px;
    overflow: hidden;
}

.variables-list {
    display: flex;
    flex-direction: column;
}

/* Variable Item */
.variable-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: var(--transition);
}

.variable-item:hover {
    background-color: var(--background-color);
}

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

.variable-item.invalid {
    background-color: var(--error-light);
}

.variable-item.encrypted {
    background-color: #f5f3ff;
}

.variable-key-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.variable-key {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    word-break: break-all;
}

.variable-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.variable-type {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.variable-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.badge-required {
    background-color: var(--warning-light);
    color: #b45309;
}

.badge-sensitive {
    background-color: #fce7f3;
    color: #be185d;
}

.badge-encrypted {
    background-color: #ddd6fe;
    color: #7c3aed;
}

.variable-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.variable-value-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.variable-value {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.value-hidden {
    color: var(--text-muted);
    font-style: italic;
}

.toggle-visibility {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.125rem;
    opacity: 0.6;
}

.toggle-visibility:hover {
    opacity: 1;
}

.variable-example {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.variable-example span {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.validation-error {
    font-size: 0.75rem;
    color: var(--error-color);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.variable-actions {
    display: flex;
    gap: 0.25rem;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    max-width: 400px;
}

/* Raw Editor */
.raw-editor-section {
    margin-top: 1.5rem;
}

.raw-editor-container {
    margin-top: 0.75rem;
}

.raw-editor-container.hidden {
    display: none;
}

.raw-editor {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    resize: vertical;
    margin-bottom: 0.75rem;
}

.raw-editor:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

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

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input.error {
    border-color: var(--error-color);
}

.error-text {
    display: block;
    font-size: 0.75rem;
    color: var(--error-color);
    margin-top: 0.25rem;
}

.error-text.hidden {
    display: none;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Import Modal Specific */
.import-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.import-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.file-input {
    display: none;
}

.file-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--background-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.file-label:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
}

.file-name {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.import-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.import-divider::before,
.import-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--border-color);
}

.import-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8125rem;
    resize: vertical;
}

.import-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Export Modal Specific */
.export-preview {
    margin-top: 1rem;
}

.export-preview label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.preview-content {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8125rem;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Encryption Warning */
.encryption-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: var(--warning-light);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    color: #92400e;
    margin-top: 1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 0;
    line-height: 1;
}

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

/* Footer */
.footer {
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .main-content {
        padding: 1rem;
    }

    .toolbar {
        flex-direction: column;
    }

    .toolbar-left, .toolbar-right {
        width: 100%;
        justify-content: flex-start;
    }

    .search-filter {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

    .variable-item {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .variable-actions {
        justify-content: flex-start;
    }

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

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

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .logo-section {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .btn {
        width: 100%;
        justify-content: center;
    }

    .variable-meta {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Utility Classes */
.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;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
