/* ============================================
   Base Styles & Reset
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-dark: #0a0e27;
    --bg-dark-secondary: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: rgba(239, 186, 186, 0.7);
    --text-tertiary: rgba(191, 209, 144, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
    --error-color: #ff6b6b;
    --success-color: #51cf66;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Main Content Layout
   ============================================ */
.main-content {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

.section {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon svg {
    flex-shrink: 0;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

/* Ensure the 'Guruhni tanlang' label displays white on all devices */
.groups-section label,
label[for="groupSelect"] {
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important; /* iOS specific */
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    color: black
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transition: all 0.3s ease;
    outline: none;
    font-family: inherit;
}

.slider {
    color: var(--text-primary);
    background: black;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus,
.form-select:focus {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-primary);
}

.required {
    color: var(--error-color);
}

/* ============================================
   Force consistent select styling across devices
   - Many mobile/desktop browsers use native controls which differ.
   - We remove native appearance and provide a consistent background,
     text color, and a custom arrow. Option styling is applied as a fallback.
   ============================================ */

.form-select,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
    border: 2px solid var(--border-color) !important;
    padding-right: 44px; /* space for arrow */
    position: relative;
}

/* Custom select wrapper to place arrow */
.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: "";
    position: absolute;
    pointer-events: none;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-primary) 50%), linear-gradient(135deg, var(--text-primary) 50%, transparent 50%);
    background-size: 50% 50%;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.9;
}

/* Option styling fallback (not all browsers support this) */
select option,
.form-select option {
    background-color: rgba(10, 14, 39, 1);
    color: var(--text-primary);
}

/* Mobile fallback: on iOS Safari the native picker is used; increase specificity
   to try to enforce colors where possible */
@media (hover: none) and (pointer: coarse) {
    .form-select,
    select {
        background-color: rgba(255, 255, 255, 0.05) !important;
        color: var(--text-primary) !important;
    }
}

/* Groups list styling */
.groups-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

/* ============================================
   Modals - See css/components/modal.css
   ============================================ */

/* Group badge styling - improved design */
.group-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.15) 100%);
    color: var(--text-primary);
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(102, 126, 234, 0.4);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.group-badge:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.2) 100%);
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Group badge inner layout */
.group-badge .group-title {
    margin-right: 8px;
    display: inline-block;
}

/* Small delete button inside group badge */
.group-delete-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.group-delete-btn:hover {
    background: rgba(255, 107, 107, 0.12);
    color: var(--error-color);
}

.group-delete-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Group item list (title + delete button aligned like company header) */
.group-entry {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-right: 16px;
    margin-bottom: 12px;
}

.group-badge-inline {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.14) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 20px;
}

/* Make icon slightly larger inside button */
.group-delete-btn i {
    font-size: 14px;
}

/* Match delete button padding/height with the badge so margins align visually */
.group-delete-btn {
    background: transparent;
    border: none;
    color: var(--error-color);
    padding: 12px 14px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.08s ease;
}

.group-delete-btn:hover {
    background: rgba(255, 107, 107, 0.08);
    transform: translateY(-1px);
}

.group-delete-btn:active {
    transform: translateY(0);
}

/* Ensure the icon itself is strong red */
.group-delete-btn i {
    color: var(--error-color);
    font-size: 16px;
}

.group-badge:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.2) 100%);
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}
/* ============================================
   Messages & Alerts
   ============================================ */
.error-message {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 8px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.2);
    border-radius: 8px;
    text-align: left;
    min-height: 20px;
}

.status-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    min-height: 20px;
}

.status-message.success {
    background: rgba(81, 207, 102, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(81, 207, 102, 0.2);
}

.status-message.error {
    background: rgba(255, 107, 107, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(255, 107, 107, 0.2);
}

.status-message.info {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* ============================================
   Utility Classes
   ============================================ */
.otp-hint {
    color: var(--text-tertiary);
    font-size: 12px;
    margin-top: 4px;
}

.otp-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
    margin-bottom: 0;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .page-container {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .page-title {
        font-size: 24px;
    }

    .companies-list {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

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

    .modal-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .otp-input {
        width: 48px;
        height: 56px;
        font-size: 24px;
    }

    .otp-input-container {
        gap: 8px;
        font-size: 12px;
        color: var(--text-secondary);
    }
}


.bank-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.bank-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.bank-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}

.bank-option-active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.15));
    border-color: rgba(139, 92, 246, 0.6);
}

.bank-option-active:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(124, 58, 237, 0.2));
    border-color: rgba(139, 92, 246, 0.8);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.bank-option-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.bank-option-disabled:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.bank-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 4px;
}

.bank-option-active .bank-icon {
    background: rgba(139, 92, 246, 0.3);
}

.bank-name {
    font-size: 14px;
    font-weight: 500;
    color: #e5e7eb;
    text-align: center;
}

.bank-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    font-weight: 500;
    margin-top: 4px;
}

.bank-badge.active {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* Warning modal styles */
.modal-small {
    max-width: 420px;
}

.warning-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: rgba(251, 191, 36, 0.15);
    border-radius: 50%;
}

.warning-icon svg {
    stroke: #fbbf24;
}

.modal-header h2 {
    text-align: center;
    margin-bottom: 0;
}

.modal-body {
    padding: 0 8px 24px;
}

.warning-message {
    font-size: 15px;
    line-height: 1.6;
    color: #d1d5db;
    text-align: center;
    margin-bottom: 12px;
}

.warning-submessage {
    font-size: 13px;
    line-height: 1.5;
    color: #9ca3af;
    text-align: center;
}

.warning-submessage strong {
    color: #8b5cf6;
    font-weight: 600;
}
