/**
 * AHB CRM — Settings Page Styles
 * "Değişimin Ruhu" 🦋 Design System
 * Sidebar + Content Area Layout with Emotional UX
 */

/* ═══════════════════════════════════════════════
   SETTINGS LAYOUT (Sidebar + Content)
   ═══════════════════════════════════════════════ */
.settings-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 60px);
    position: relative;
}

/* ═══════════════════════════════════════════════
   HERO BANNER — "Shape Your Experience" 🦋
   ═══════════════════════════════════════════════ */
.settings-hero {
    position: relative;
    padding: 28px 32px;
    border-radius: 16px;
    margin-bottom: 24px;
    overflow: hidden;
    background: linear-gradient(135deg,
            rgba(20, 184, 166, 0.12) 0%,
            rgba(139, 92, 246, 0.10) 50%,
            rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(20, 184, 166, 0.15);
}

.settings-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(20, 184, 166, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 60%);
    animation: heroMesh 12s ease-in-out infinite;
    pointer-events: none;
}

@keyframes heroMesh {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(2%, -1%) rotate(1deg);
    }

    66% {
        transform: translate(-1%, 2%) rotate(-1deg);
    }
}

.settings-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.settings-hero-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 8px rgba(20, 184, 166, 0.3));
    animation: heroButterfly 4s ease-in-out infinite;
}

@keyframes heroButterfly {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-3px) rotate(2deg);
    }

    75% {
        transform: translateY(2px) rotate(-1deg);
    }
}

.settings-hero h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary, #14b8a6) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.settings-hero p {
    margin: 4px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    opacity: 0.85;
}

/* ═══════════════════════════════════════════════
   SIDEBAR NAVIGATION
   ═══════════════════════════════════════════════ */
.settings-sidebar {
    width: 250px;
    min-width: 250px;
    border-right: 1px solid var(--border-color);
    padding: 16px 0;
    background: var(--card-bg, #fff);
    border-radius: 12px 0 0 12px;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

.settings-nav-group {
    margin-bottom: 4px;
}

.settings-nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    user-select: none;
    margin-top: 8px;
}

.settings-nav-group-title:first-child {
    margin-top: 0;
}

.settings-nav-group-icon {
    font-size: 0.9rem;
    opacity: 0.7;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px 9px 36px;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.settings-nav-item:hover {
    background: var(--hover-bg, rgba(20, 184, 166, 0.06));
    color: var(--primary, #14b8a6);
    transform: translateX(2px);
}

.settings-nav-item.active {
    background: linear-gradient(90deg, rgba(20, 184, 166, 0.10) 0%, transparent 100%);
    color: var(--primary, #14b8a6);
    font-weight: 600;
    border-left-color: var(--primary, #14b8a6);
}

.settings-nav-item.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary, #14b8a6);
    border-radius: 3px 0 0 3px;
    opacity: 0.5;
}

.settings-nav-item-icon {
    font-size: 0.9rem;
    width: 20px;
    text-align: center;
    opacity: 0.7;
}

.settings-nav-item.active .settings-nav-item-icon {
    opacity: 1;
}

/* ═══════════════════════════════════════════════
   CONTENT AREA
   ═══════════════════════════════════════════════ */
.settings-content {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
    overflow-x: visible;
    max-height: calc(100vh - 180px);
}

.settings-section {
    animation: settingsFadeIn 0.3s ease-out;
}

@keyframes settingsFadeIn {
    from {
        opacity: 0;
        transform: translateX(12px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.settings-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text-color);
    position: relative;
}

.settings-section-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 20px;
}

/* Settings Cards */
.settings-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    overflow: visible;
    position: relative;
}

.settings-card:hover {
    border-color: rgba(20, 184, 166, 0.2);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.settings-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.settings-card-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Form Enhancements */
.settings-form-group {
    margin-bottom: 16px;
}

.settings-form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-color);
}

.settings-form-group .form-control {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-form-group .form-control:focus {
    border-color: var(--primary, #14b8a6);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

/* Save Button Enhancement */
.settings-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary, #14b8a6) 0%, #0d9488 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.settings-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(20, 184, 166, 0.3);
}

.settings-save-btn:active {
    transform: translateY(0);
}

.settings-save-btn.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    animation: savePulse 0.4s ease;
}

@keyframes savePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ═══════════════════════════════════════════════
   LIST ITEMS (Personas, Webhooks, Fields, etc.)
   ═══════════════════════════════════════════════ */
.settings-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.15s ease;
    border-radius: 8px;
    margin-bottom: 4px;
}

.settings-list-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-list-item:hover {
    background: var(--hover-bg, rgba(20, 184, 166, 0.04));
}

.settings-list-item-info {
    flex: 1;
    min-width: 0;
}

.settings-list-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
}

.settings-list-item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.settings-list-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.settings-list-item-actions .btn {
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.8rem;
    transition: all 0.15s ease;
}

.settings-list-item-actions .btn:hover {
    transform: scale(1.08);
}

/* Empty State */
.settings-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.settings-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.settings-empty p {
    font-size: 0.85rem;
    margin: 0;
}

/* ═══════════════════════════════════════════════
   HELP TOOLTIP — (?) icon with popover
   ═══════════════════════════════════════════════ */
.settings-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(20, 184, 166, 0.1);
    color: var(--primary, #14b8a6);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: help;
    margin-left: 6px;
    vertical-align: middle;
    transition: all 0.2s ease;
    position: relative;
    border: 1px solid rgba(20, 184, 166, 0.2);
    user-select: none;
}

.settings-help-icon:hover {
    background: rgba(20, 184, 166, 0.2);
    transform: scale(1.15);
    z-index: 99999;
}

/* Original inline tooltips hidden — JS floating tooltip is used instead */
.settings-help-icon .help-tooltip {
    display: none !important;
}

/* Floating tooltip rendered via JS, appended to body */
#settings-tooltip-float {
    position: fixed;
    width: 300px;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 0.8rem;
    font-weight: 400;
    color: #1e293b;
    line-height: 1.5;
    z-index: 999999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#settings-tooltip-float.visible {
    opacity: 1;
}

#settings-tooltip-float::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-bottom-color: #ffffff;
}

[data-theme="dark"] #settings-tooltip-float {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] #settings-tooltip-float::before {
    border-bottom-color: #1e293b;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ═══════════════════════════════════════════════
   FORM HINT TEXT — subtle guidance under inputs
   ═══════════════════════════════════════════════ */
.settings-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.4;
    opacity: 0.75;
}

.settings-hint code {
    background: rgba(20, 184, 166, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: var(--font-mono, monospace);
}

/* ═══════════════════════════════════════════════
   EMPTY STATE — Step-by-step Guide
   ═══════════════════════════════════════════════ */
.settings-empty-guide {
    text-align: center;
    padding: 36px 20px;
}

.settings-empty-guide .empty-icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
    opacity: 0.35;
}

.settings-empty-guide .empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 6px;
}

.settings-empty-guide .empty-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.settings-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
    margin: 0 auto 20px;
    text-align: left;
}

.settings-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(20, 184, 166, 0.04);
    border: 1px solid rgba(20, 184, 166, 0.08);
    transition: all 0.2s ease;
}

.settings-step:hover {
    background: rgba(20, 184, 166, 0.08);
    transform: translateX(3px);
}

.settings-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #14b8a6), #0d9488);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.settings-step-text {
    font-size: 0.82rem;
    color: var(--text-color);
    line-height: 1.4;
}

.settings-step-text strong {
    color: var(--primary, #14b8a6);
}

/* ═══════════════════════════════════════════════
   LEARN MORE LINK
   ═══════════════════════════════════════════════ */
.settings-learn-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--primary, #14b8a6);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    opacity: 0.8;
}

.settings-learn-more:hover {
    opacity: 1;
    transform: translateX(2px);
}

.settings-learn-more::after {
    content: '→';
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.settings-learn-more:hover::after {
    transform: translateX(3px);
}

/* ═══════════════════════════════════════════════
   WA CHANNEL STYLES (moved from inline)
   ═══════════════════════════════════════════════ */
.wa-connect-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px;
    text-align: center;
}

.wa-connect-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(37, 211, 102, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    transition: transform 0.3s ease;
}

.wa-connect-icon:hover {
    transform: scale(1.05);
}

.wa-connect-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 12px rgba(37, 211, 102, 0.25);
}

.wa-connect-btn:hover {
    background: #1da851;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35);
}

.wa-connect-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.wa-connect-btn .spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.wa-account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.wa-account-row:last-child {
    border-bottom: none;
}

.wa-account-info {
    flex: 1;
}

.wa-account-phone {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 4px 0 2px;
}

.wa-account-name {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.wa-account-meta {
    display: flex;
    gap: 12px;
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: var(--font-mono, monospace);
}

.wa-account-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 12px;
}

.wa-account-status.active {
    background: rgba(37, 211, 102, 0.1);
    color: #25D366;
}

.wa-account-status.inactive {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
}

.wa-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.wa-not-configured {
    padding: 12px 16px;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.2);
    border-radius: 8px;
}

/* Default badge */
.default-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    background: rgba(20, 184, 166, 0.12);
    color: var(--primary, #14b8a6);
    margin-left: 6px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════
   STAGGERED LOAD ANIMATION
   ═══════════════════════════════════════════════ */
.settings-stagger-1 {
    animation-delay: 0.05s;
}

.settings-stagger-2 {
    animation-delay: 0.1s;
}

.settings-stagger-3 {
    animation-delay: 0.15s;
}

.settings-stagger-4 {
    animation-delay: 0.2s;
}

.settings-stagger-5 {
    animation-delay: 0.25s;
}

/* ═══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .settings-layout {
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        border-radius: 12px 12px 0 0;
        max-height: none;
        padding: 8px 0;
        overflow-x: auto;
        display: flex;
        flex-wrap: wrap;
        gap: 0;
    }

    .settings-nav-group {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 0;
    }

    .settings-nav-group-title {
        display: none;
    }

    .settings-nav-item {
        padding: 8px 14px;
        border-left: none;
        border-bottom: 2px solid transparent;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .settings-nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary, #14b8a6);
        background: transparent;
    }

    .settings-nav-item.active::after {
        display: none;
    }

    .settings-content {
        padding: 16px;
        max-height: none;
    }

    .settings-hero {
        padding: 20px;
        margin-bottom: 16px;
        border-radius: 12px;
    }

    .settings-hero h2 {
        font-size: 1.05rem;
    }

    .settings-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .settings-hero-content {
        flex-direction: column;
        text-align: center;
    }

    .settings-card-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .settings-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .settings-list-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .wa-account-meta {
        flex-wrap: wrap;
    }
}

/* ═══════════════════════════════════════════════
   DARK MODE ADJUSTMENTS
   ═══════════════════════════════════════════════ */
[data-theme="dark"] .settings-hero {
    background: linear-gradient(135deg,
            rgba(20, 184, 166, 0.08) 0%,
            rgba(139, 92, 246, 0.06) 50%,
            rgba(59, 130, 246, 0.04) 100%);
    border-color: rgba(20, 184, 166, 0.1);
}

[data-theme="dark"] .settings-sidebar {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .settings-card:hover {
    border-color: rgba(20, 184, 166, 0.15);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .settings-nav-item:hover {
    background: rgba(20, 184, 166, 0.08);
}

[data-theme="dark"] .settings-list-item:hover {
    background: rgba(20, 184, 166, 0.06);
}