/* Custom Reset & CSS Variables */
:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.4);
    --bg-sidebar: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #10b981;
    --danger: #ef4444;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* App Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    min-width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #10b981);
    box-shadow: 0 0 15px var(--accent-glow);
}

.brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

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

.country-list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.country-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.country-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.country-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.country-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.country-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.country-flag {
    font-size: 1.1rem;
}

.country-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.country-item.active .country-name {
    color: #a5b4fc;
}

.country-code {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
}

/* Workspace Area */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Blank State styling */
.blank-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.blank-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

.blank-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.blank-state p {
    max-width: 420px;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Active Workspace styling */
.country-workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 40px;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.workspace-title-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.code-badge {
    background: linear-gradient(135deg, var(--accent), #10b981);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.workspace-title-area h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.workspace-actions {
    display: flex;
    gap: 12px;
}

.workspace-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

/* SNI Grid / Cards styling */
.sni-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    align-items: start;
}

.sni-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(8px);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.sni-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    opacity: 0.6;
}

.sni-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.15);
}

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

.sni-badge-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-method {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-port {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

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

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.action-btn.delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.sni-host-row {
    margin-bottom: 12px;
}

.sni-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    font-weight: 600;
}

.sni-value {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: #fff;
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 8px;
}

.copy-mini-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px;
    transition: var(--transition-fast);
}

.copy-mini-btn:hover {
    color: var(--accent);
}

.sni-meta-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.meta-item {
    font-size: 0.85rem;
}

.meta-val {
    color: var(--text-secondary);
    margin-top: 2px;
}

.sni-payload-box {
    margin-top: 14px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.sni-payload-box code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #34d399;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

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

.btn-danger-text:hover {
    background: rgba(239, 68, 68, 0.08);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: var(--transition-normal);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 580px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    z-index: 101;
    transform: scale(0.95);
    transition: var(--transition-normal);
}

.modal.hidden .modal-content {
    transform: scale(0.9);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--glass-border);
}

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

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.modal-body {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.col {
    flex: 1;
}

.col-small {
    width: 100px;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"], textarea {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

textarea {
    font-family: var(--font-mono);
    resize: vertical;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--accent);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 250px;
    animation: slideIn 0.3s forwards cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

.toast.toast-error {
    border-left-color: var(--danger);
}

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

.hidden {
    display: none !important;
}
