/* Settings Container Layout */
.settings-container {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Settings Navigation Sidebar */
.settings-nav {
    width: 220px;
    flex-shrink: 0;
}

.settings-nav h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.settings-nav nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.settings-nav-link:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.settings-nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.settings-nav-link .nav-icon {
    font-size: 1.25rem;
}

/* Settings Content Area */
.settings-content {
    flex: 1;
    min-width: 0;
}

.settings-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.settings-content .subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Settings Sections */
.settings-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.settings-section .section-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Avatar Section */
.avatar-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    font-size: 3rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.avatar-input {
    display: none;
}

/* Avatar Cropper Modal */
.crop-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 0.5rem;
    overflow-y: auto;
}

.crop-modal {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: auto;
}

.crop-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.crop-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.crop-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.crop-modal-close:hover {
    color: var(--text-primary);
}

.crop-modal-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.crop-container {
    position: relative;
    width: 100%;
    height: 280px;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.crop-image {
    max-width: 100%;
    max-height: 280px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.1s ease-out;
    /* Remove position changes - let the wrapper handle positioning */
}

/* Wrapper created by JS to contain both image and overlay */
.crop-image-wrapper {
    position: relative;
    display: block;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Circular crop box with dark overlay outside */
.crop-box {
    position: absolute;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    cursor: move;
    pointer-events: auto;
    overflow: visible;
}

/* Visible circular border */
.crop-circle-border {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    pointer-events: auto;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.crop-handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.crop-handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.crop-handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.crop-handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* Zoom Controls */
.crop-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--surface-color);
    border-radius: 8px;
}

/* Position/Direction controls */
.position-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.position-row {
    display: flex;
    gap: 2px;
}

.position-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 1.1rem;
    padding: 0;
    touch-action: manipulation;
}

.position-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.position-btn:active {
    transform: scale(0.95);
    background: var(--primary-color);
    color: white;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.zoom-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.zoom-btn:active {
    background: var(--primary-color);
    color: white;
}

.zoom-icon {
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1;
}

.zoom-slider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.zoom-level {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 45px;
    text-align: center;
}

/* Padding Controls */
.padding-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.padding-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.padding-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.padding-color-options {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.padding-color-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.padding-color-btn:hover {
    transform: scale(1.1);
}

.padding-color-btn.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* White color button needs a visible border */
.padding-color-btn[style*="#FFFFFF"] {
    border-color: #999;
}

.padding-color-btn.selected[style*="#FFFFFF"] {
    border-color: var(--primary-color);
}

.padding-color-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.crop-preview-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.crop-preview-section span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.crop-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--hover-bg);
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}

.crop-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.crop-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--card-bg);
}

/* Mobile-specific crop modal styles */
@media (max-width: 480px) {
    .crop-modal-overlay {
        padding: 0;
        align-items: flex-start;
    }
    
    .crop-modal {
        max-height: 100vh;
        border-radius: 0;
        height: 100vh;
    }
    
    .crop-modal-body {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .crop-container {
        height: 200px;
    }
    
    .crop-image {
        max-height: 200px;
    }
    
    .crop-controls {
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .position-btn {
        width: 40px;
        height: 40px;
    }
    
    .zoom-btn {
        width: 40px;
        height: 40px;
    }
    
    .zoom-slider {
        width: 80px;
    }
    
    .padding-toggle span {
        font-size: 0.85rem;
    }
    
    .crop-preview-section {
        flex-direction: row;
        justify-content: center;
    }
    
    .crop-preview {
        width: 60px;
        height: 60px;
    }
    
    .crop-modal-footer {
        padding: 0.75rem;
    }
}

/* Preset Avatars */
.preset-avatars {
    width: 100%;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.preset-avatars h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
}

.preset-item {
    position: relative;
    width: 80px;
    height: 80px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: none;
    padding: 0;
}

.preset-item:hover:not(:disabled) {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.preset-item.premium {
    opacity: 0.6;
}

.preset-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preset-name {
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    white-space: nowrap;
}

.premium-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: gold;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

/* Form Styles */
.profile-form,
.change-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Password Input with Toggle */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper .form-control {
    padding-right: 45px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.password-toggle:hover {
    opacity: 1;
}

.password-toggle .toggle-icon {
    font-size: 1rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-hint.char-count {
    text-align: right;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Current Value Display */
.current-value,
.pending-change {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.current-value .label,
.pending-change .label {
    color: var(--text-secondary);
    min-width: 120px;
}

.current-value .value,
.pending-change .value {
    font-weight: 500;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* Phone Input Group */
.phone-input-group {
    display: flex;
    align-items: stretch;
}

.phone-prefix {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
    justify-content: center;
}

.phone-number-input {
    border-radius: 0 8px 8px 0 !important;
    flex: 1;
}

/* Verified Badge */
.verified-badge {
    color: #22c55e;
    font-weight: 600;
}

/* Info/Warning Messages */
.info-message,
.warning-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.info-message {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.warning-message {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* Danger Zone */
.danger-zone {
    border-color: rgba(239, 68, 68, 0.3);
}

.danger-zone h3 {
    color: #ef4444;
}

.delete-confirmation {
    background: rgba(239, 68, 68, 0.05);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.delete-confirmation h4 {
    color: #ef4444;
    margin-bottom: 1rem;
}

.delete-confirmation ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.delete-confirmation li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.deletion-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.deletion-warning h4 {
    color: #f59e0b;
    margin-bottom: 0.5rem;
}

/* Two-Factor Authentication */
.two-factor-status {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    width: fit-content;
}

.status-badge.enabled {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-badge.disabled {
    background: rgba(156, 163, 175, 0.1);
    color: #9ca3af;
}

.status-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Linked Accounts */
.linked-accounts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.linked-account {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--hover-bg);
    border-radius: 8px;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.provider-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: 8px;
}

.account-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.provider-name {
    font-weight: 500;
    text-transform: capitalize;
}

.account-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.linked-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.link-new-account {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.link-new-account h4 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.provider-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-provider {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: #333333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-provider:hover {
    border-color: var(--primary-color);
    background: #f5f5f5;
}

.btn-provider.google { 
    background: #ffffff;
    border-color: #dadce0;
}
.btn-provider.google:hover { 
    border-color: #ea4335; 
    background: #fef7f6;
}

.btn-provider.apple { 
    background: #000000;
    color: #ffffff;
    border-color: #000000;
}
.btn-provider.apple:hover { 
    background: #333333;
    border-color: #333333;
}

.btn-provider.discord:hover { border-color: #5865f2; }

/* Sessions */
.sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--hover-bg);
    border-radius: 8px;
}

.session-item.current {
    border: 1px solid var(--primary-color);
    background: rgba(var(--primary-rgb), 0.05);
}

.session-icon {
    font-size: 1.5rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: 12px;
}

.session-details {
    flex: 1;
    min-width: 0;
}

.session-device {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.current-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-weight: 500;
}

.trusted-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: var(--success-color, #28a745);
    color: white;
    border-radius: 4px;
    font-weight: 500;
}

.session-item.trusted {
    border-left: 3px solid var(--success-color, #28a745);
}

.session-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-success-outline {
    color: var(--success-color, #28a745);
    border: 1px solid var(--success-color, #28a745);
    background: transparent;
}

.btn-success-outline:hover {
    background: var(--success-color, #28a745);
    color: white;
}

.session-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.session-created {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Security Timeline */
.security-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--hover-bg);
    border-radius: 8px;
}

.timeline-icon {
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: 8px;
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.timeline-title {
    font-weight: 500;
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Empty States */
.no-items {
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .settings-container {
        flex-direction: column;
        padding: 1rem;
    }

    .settings-nav {
        width: 100%;
    }

    .settings-nav nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .settings-nav-link {
        white-space: nowrap;
    }

    .avatar-section {
        flex-direction: column;
        align-items: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .session-item {
        flex-direction: column;
        text-align: center;
    }

    .sessions-header {
        flex-direction: column;
        gap: 0.5rem;
    }
}
