/* ===========================
   Carbon Panel - Mobile Styles
   =========================== */

@media (max-width: 900px) { .generate-grid { grid-template-columns: 1fr; } }

    /* ── Keys section toolbar ── */
    .section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
    .section-toolbar h2 { margin: 0; font-size: 20px; }
    .toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
    .search-input { width: 240px; margin: 0; padding: 9px 14px; font-size: 14px; }
    @media (max-width: 900px) { .search-input { width: 100%; } .section-toolbar { flex-direction: column; align-items: flex-start; } }

    /* ── Auth ── */
    .auth-container { max-width: 420px; margin: 60px auto; padding: 0 20px; }
    .auth-nav { display: flex; justify-content: center; gap: 16px; margin-bottom: 20px; }
    .auth-nav a { font-size: 16px; font-weight: 600; color: var(--primary-color); text-decoration: none; padding: 8px 18px; border-radius: 8px; transition: background 0.2s; }
    .auth-nav a.active { background: var(--primary-color); color: white; }
    .auth-nav a:hover:not(.active) { background: var(--light-color); }

    /* ── Forms ── */
    .form-group { margin-bottom: 16px; }
    label { display: block; margin-bottom: 6px; font-weight: 500; }
    select, input, textarea { width: 100%; padding: 11px 14px; border-radius: 8px; border: 1px solid var(--border); font-size: 15px; transition: all 0.2s; margin-bottom: 0; background: var(--input-bg); color: var(--text); }
    select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(67,97,238,0.15); }
    button { width: 100%; padding: 11px 14px; border-radius: 8px; cursor: pointer; background: var(--primary-color); color: #fff; border: none; font-weight: 600; font-size: 15px; transition: transform 0.15s, background 0.2s; margin-top: 4px; }
    body.dark-mode button { color: #fff !important; }
    button:hover { background: #3a53ca; transform: translateY(-1px); }
    .btn-secondary { background: var(--warning-color); }
    .btn-secondary:hover { background: #e68a00; }
    .btn-danger { background: var(--danger-color); }
    .btn-danger:hover { background: #d90429; }

    /* ── Sections ── */
    .section { display: none; }
    .section.active { display: block; animation: sectionFadeIn 0.2s ease both; }
    @keyframes sectionFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

    /* ── Confirmation toast ── */
    .confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); backdrop-filter: blur(3px); z-index: 5000; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.15s ease; }
    .confirm-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 28px 22px; max-width: 380px; width: 90%; box-shadow: 0 12px 40px rgba(0,0,0,0.2); animation: modalFadeIn 0.2s ease; text-align: center; }
    .confirm-icon { font-size: 36px; margin-bottom: 12px; }
    .confirm-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
    .confirm-message { font-size: 14px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.5; }
    .confirm-buttons { display: flex; gap: 10px; justify-content: center; }
    .confirm-buttons button { width: auto; flex: 1; padding: 10px 20px; font-size: 14px; margin: 0; border-radius: 8px; }
    .confirm-cancel { background: var(--surface-2) !important; color: var(--text) !important; border: 1px solid var(--border) !important; }
    .confirm-cancel:hover { background: var(--border) !important; }

    /* ── Key list ── */
    .key-item {
        background: var(--surface-2);
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 12px;
        list-style: none;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        transition: transform 0.15s;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 16px;
        flex-wrap: wrap;
    }
    .key-item:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
    .key-content { flex: 1; min-width: 0; }
    .key-content strong { font-size: 16px; display: block; margin-bottom: 6px; color: var(--primary-color); word-break: break-all; }
    .key-details { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; color: #555; }
    .key-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: flex-start; flex-wrap: wrap; }
    .action-btn { margin: 0; padding: 8px 14px; width: auto; flex: none; font-size: 13px; }
    .copy-btn { background: var(--success-color); }
    .copy-btn:hover { background: #208b7f; }

    /* ── Key history (dashboard) ── */
    .key-history-list { list-style: none; padding: 0; }
    .key-history-item { background: var(--surface-2); padding: 12px 16px; border-radius: 8px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
    .key-history-item > div { flex: 1; min-width: 0; word-break: break-all; }
    .key-history-item .action-btn { flex-shrink: 0; }

    /* ── Pricing grid ── */
    .key-pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 15px 0; }
    .price-item { text-align: center; padding: 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px; color: var(--text); }

    /* ── Tables ── */
    .table-container { overflow-x: auto; }
    table { width: 100%; border-collapse: collapse; margin-top: 16px; }
    th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
    th { background: var(--light-color); font-weight: 600; }

    /* ── Status badges ── */
    .status-badge { padding: 3px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
    .status-active { background: #d4edda; color: #155724; }
    .status-inactive { background: #f8d7da; color: #721c24; }

    /* ── Referrals ── */
    .referral-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 16px; }
    .referral-card { background: var(--surface); border-radius: var(--border-radius); padding: 20px; box-shadow: var(--box-shadow); border-left: 4px solid var(--primary-color); min-width: 260px; max-width: 260px; flex-shrink: 0; }
    .referral-code { font-family: monospace; font-size: 17px; font-weight: bold; color: var(--primary-color); margin: 8px 0; word-break: break-all; }

    /* ── User info grid ── */
    .user-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 16px; }
    .user-info-item { background: var(--surface-2); padding: 14px; border-radius: var(--border-radius); text-align: center; font-size: 14px; }

    /* ── Modals ── */
    .modal, .add-credits-modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
    .modal-content, .add-credits-modal-content { background: var(--surface); margin: 8% auto; padding: 28px; border-radius: var(--border-radius); width: 90%; max-width: 500px; box-shadow: var(--box-shadow); animation: modalFadeIn 0.25s; }
    @keyframes modalFadeIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
    .close { float: right; font-size: 26px; font-weight: bold; color: #aaa; cursor: pointer; line-height: 1; }
    .close:hover { color: var(--dark-color); }
    .user-info-display { background: var(--light-color); padding: 16px; border-radius: 8px; margin-bottom: 16px; }
    .user-info-display div { margin-bottom: 8px; font-size: 15px; }
    .user-info-display strong { color: var(--primary-color); }

    /* ── Toast ── */
    #toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; }
    .toast { min-width: 280px; margin-top: 10px; padding: 14px 18px; border-radius: var(--border-radius); background: var(--surface); color: var(--text); box-shadow: 0 5px 15px rgba(0,0,0,0.2); display: flex; align-items: center; animation: slideIn 0.3s forwards, fadeOut 0.5s 3.5s forwards; }
    .toast.success { border-left: 5px solid var(--success-color); }
    .toast.warning { border-left: 5px solid var(--warning-color); }
    .toast.error { border-left: 5px solid var(--danger-color); }
    .toast-icon { margin-right: 12px; font-size: 22px; }
    .toast-content { flex: 1; }
    .toast-title { font-weight: 600; margin-bottom: 3px; }
    .toast-message { font-size: 13px; opacity: 0.9; }
    @keyframes slideIn { from { transform: translateX(110%); } to { transform: translateX(0); } }
    @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateX(110%); } }

    /* ── Expiration warnings ── */
    .expiration-banner { background: #d4edda; color: #155724; padding: 14px; border-radius: var(--border-radius); text-align: center; font-weight: 600; margin-bottom: 20px; }
    .expiration-warning { padding: 14px; border-radius: var(--border-radius); text-align: center; font-weight: 600; margin-bottom: 20px; }
    .expiration-expired { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
    .expiration-soon { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }

    /* ── Account expired overlay ── */
    .account-expired-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px); z-index: 10000; display: none; justify-content: center; align-items: center; }
    .account-expired-message { background: white; padding: 40px; border-radius: var(--border-radius); text-align: center; max-width: 480px; width: 90%; box-shadow: 0 10px 30px rgba(0,0,0,0.3); animation: modalFadeIn 0.3s; }
    .account-expired-message h2 { color: var(--danger-color); margin-bottom: 16px; }
    .account-expired-message p { font-size: 17px; margin-bottom: 14px; line-height: 1.6; }
    .logout-countdown { background: #f8d7da; color: #721c24; padding: 14px; border-radius: 8px; margin-top: 20px; border: 1px solid #f5c6cb; text-align: center; font-weight: bold; }
    .countdown-number { font-size: 24px; color: var(--danger-color); font-weight: bold; }
    .account-expired .page-body, .account-expired .navbar, .account-expired .top-header { pointer-events: none; opacity: 0.3; }

    /* ── Maintenance overlay ── */
    .maintenance-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.55); backdrop-filter: blur(8px); z-index: 10001; display: none; justify-content: center; align-items: center; }
    .maintenance-content { background: white; padding: 40px 45px; border-radius: 16px; text-align: center; max-width: 480px; width: 90%; box-shadow: 0 10px 40px rgba(0,0,0,0.2); animation: slideUp 0.4s; border: 1px solid #e0e0e0; }
    .maintenance-icon { font-size: 56px; color: #4361ee; margin-bottom: 16px; animation: floatAnim 3s ease-in-out infinite; }
    .maintenance-content h1 { font-size: 26px; color: #2d3748; margin-bottom: 12px; font-weight: 700; }
    .maintenance-content p { font-size: 15px; color: #718096; line-height: 1.6; margin-bottom: 12px; }
    .maintenance-status { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 10px 24px; border-radius: 50px; display: inline-block; font-weight: 600; font-size: 14px; margin-top: 16px; }
    .maintenance-logout-btn { margin-top: 22px; padding: 11px 26px; background: white; color: #4361ee; border: 2px solid #4361ee; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; width: auto; transition: all 0.2s; }
    .maintenance-logout-btn:hover { background: #4361ee; color: white; transform: translateY(-2px); }
    .maintenance-mode .page-body, .maintenance-mode .navbar, .maintenance-mode .top-header { pointer-events: none; opacity: 0.3; }
    @keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes floatAnim { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

    /* ── Responsive ── */
    @media (max-width: 900px) {
        /* Switch to mobile layout */
        .pc-nav-links { display: none; }
        .pc-user-dropdown { display: none; }
        .hamburger-button { display: flex !important; }
        .dropdown { display: block !important; }
        .navbar { display: flex !important; background: white; border-radius: var(--border-radius); padding: 14px 18px; margin-bottom: 16px; justify-content: space-between; align-items: center; box-shadow: var(--box-shadow); flex-wrap: wrap; gap: 10px; }
        .nav-brand { font-size: 18px; font-weight: 700; color: var(--primary-color); }
        .nav-user-info { display: flex; align-items: center; gap: 10px; }
        .top-header { background: #000; padding: 0 18px; }
        .top-header-title { color: #fff; }
        .hamburger-icon span { background: #fff; }
        .dashboard-grid { grid-template-columns: 1fr; }
        .dashboard-right { gap: 16px; }
        .key-item { flex-direction: column; }
        .key-actions { width: 100%; }
        .action-btn { flex: 1; }
        .dropdown-content { width: 100%; border-radius: 0; top: 60px; }
        .page-body { padding: 14px 16px; }
        .welcome-bar { display: none; }
    }