/* Modern CSS Variables */
:root {
    --primary-color: #6366f1; /* Indigo 500 */
    --primary-hover: #4f46e5; /* Indigo 600 */
    --danger-color: #ef4444;  /* Red 500 */
    --danger-hover: #dc2626;  /* Red 600 */
    --success-color: #10b981; /* Emerald 500 */
    --success-hover: #059669; /* Emerald 600 */
    
    --bg-color: #f8fafc;      /* Slate 50 */
    --card-bg: #ffffff;
    --text-main: #334155;     /* Slate 700 */
    --text-heading: #0f172a;  /* Slate 900 */
    --text-muted: #64748b;    /* Slate 500 */
    
    --border-color: #e2e8f0;  /* Slate 200 */
    --input-bg: #f8fafc;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-focus: 0 0 0 3px rgba(99, 102, 241, 0.2);
    
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: 'Fira Code', 'Cascadia Code', 'Courier New', Courier, monospace;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

h1, h2, h3, h4 {
    color: var(--text-heading);
    font-weight: 700;
    line-height: 1.2;
}

h2 { margin-bottom: 1.5rem; font-size: 1.75rem; }
h3 { margin-bottom: 1rem; font-size: 1.25rem; }

/* Header & Navigation */
header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s ease;
    font-size: 0.95rem;
}

nav a:hover {
    color: var(--primary-color);
}

/* Cards & Sections */
.card, .group-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

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

.group-title {
    color: var(--text-heading);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Accordions (Viewer Snippets) */
.accordion {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.accordion-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s ease;
}

.accordion-item:hover {
    border-color: #cbd5e1;
}

.accordion-header {
    padding: 1.25rem 1.5rem;
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-heading);
    user-select: none;
    transition: background-color 0.2s ease;
}

.accordion-header:hover {
    background: var(--bg-color);
}

.accordion-header .icon {
    color: var(--text-muted);
    font-size: 1.25rem;
    font-weight: 400;
    transition: transform 0.3s ease;
}

.accordion-content {
    display: none;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #fdfdfd;
}

.accordion-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Easy Editor */
.easy-edit-box {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.easy-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.easy-edit-header strong {
    color: var(--text-heading);
    font-size: 0.95rem;
}

.kv-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.kv-row input {
    flex: 1;
}

/* Code Areas */
.json-edit-area, pre {
    width: 100%;
    background: #1e293b; /* Slate 800 */
    color: #f8fafc;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    border: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    line-height: 1.5;
}

.json-edit-area {
    resize: vertical;
    min-height: 200px;
}

.json-edit-area:focus {
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 0 0 2px var(--primary-color);
}

.content-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.edit-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-heading);
}

input[type="text"], input[type="password"], textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    box-shadow: var(--shadow-focus);
}

/* JSON Key Picker */
#json-key-picker {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

#key-tree div {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--primary-hover);
    transition: all 0.15s ease;
}

#key-tree div:hover {
    color: var(--text-heading);
    transform: translateX(4px);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    background-color: var(--border-color);
    color: var(--text-heading);
    transition: all 0.2s ease;
    user-select: none;
}

.btn:hover {
    background-color: #cbd5e1;
}

.btn:active {
    transform: translateY(1px);
}

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

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

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

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

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

.btn-copy:hover {
    background-color: var(--success-hover);
    box-shadow: var(--shadow-md);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Admin list items */
.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    background: var(--card-bg);
    transition: border-color 0.2s;
}

.admin-item:hover {
    border-color: #cbd5e1;
}

.admin-item-title {
    font-weight: 600;
    color: var(--text-heading);
}

.admin-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Form Actions Layout */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    header {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    header .container {
        flex-direction: column;
        gap: 1rem;
    }

    nav {
        width: 100%;
        justify-content: space-around;
        gap: 0;
    }

    .card, .group-section {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .kv-row {
        flex-direction: column;
        align-items: stretch;
        background: #fff;
        padding: 1rem;
        border-radius: var(--radius-md);
        border: 1px solid var(--border-color);
    }
    
    .kv-row button {
        margin-top: 0.5rem;
    }

    .content-actions {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .admin-item {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .admin-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }

    .easy-edit-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
}