/* ── Instralabs Portal Styles ── */

/* Auth Page */
.il-auth-container {
    max-width: 460px;
    margin: 40px auto;
    padding: 0 20px;
}

.il-auth-card {
    background: #fff;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.il-auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 25px;
    border-bottom: 2px solid #eee;
}

.il-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 16px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.il-tab:hover {
    color: #333;
}

.il-tab-active {
    color: #222;
    border-bottom-color: #2a5bff;
}

/* Forms */
.il-form,
.il-form-inline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.il-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 14px;
    color: #333;
}

.il-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.il-field input:focus {
    outline: none;
    border-color: #2a5bff;
    box-shadow: 0 0 0 3px rgba(42, 91, 255, 0.1);
}

.il-field small {
    display: block;
    margin-top: 4px;
    color: #888;
    font-size: 13px;
}

/* Buttons */
.il-button {
    display: inline-block;
    padding: 11px 22px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
    text-align: center;
}

.il-button-primary {
    background: #2a5bff;
    color: #fff;
    border-color: #2a5bff;
}

.il-button-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.il-button-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.il-button-secondary {
    background: #eee;
    color: #333;
    border-color: #eee;
}

.il-button-secondary:hover {
    background: #ddd;
    border-color: #ddd;
}

.il-button-outline {
    background: transparent;
    color: #333;
    border-color: #ccc;
}

.il-button-outline:hover {
    border-color: #999;
}

.il-forgot,
.il-back {
    text-align: center;
    margin: 0;
    font-size: 14px;
}

.il-forgot a,
.il-back a {
    color: #2a5bff;
}

/* Messages */
.il-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.il-message-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.il-message-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Portal Page */
.il-portal-container {
    max-width: 1100px;
    margin: 30px auto;
    padding: 0 20px;
}

.il-portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 12px;
}

.il-portal-header h2 {
    margin: 0;
    font-size: 28px;
}

.il-portal-actions {
    display: flex;
    gap: 10px;
}

.il-portal-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 25px;
}

@media (max-width: 768px) {
    .il-portal-grid {
        grid-template-columns: 1fr;
    }
}

.il-panel {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.il-panel h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
}

/* Account Details */
.il-account-row {
    margin-bottom: 8px;
    font-size: 14px;
}

.il-account-row strong {
    display: inline-block;
    width: 80px;
}

/* Licence Table */
.il-licence-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.il-licence-table th,
.il-licence-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.il-licence-table th {
    font-weight: 600;
    color: #555;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.il-licence-key {
    font-family: monospace;
    background: #f4f6fb;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid #e5e7eb;
}

.il-licence-key:hover {
    background: #edf0f7;
}

/* Collapsed state: show truncated, hide full */
.il-key-collapsed .il-key-text {
    display: inline;
}

.il-key-collapsed .il-key-full {
    display: none;
}

/* Expanded state: hide truncated, show full */
.il-key-expanded .il-key-text {
    display: none;
}

.il-key-expanded .il-key-full {
    display: inline;
    word-break: break-all;
    line-height: 1.5;
}

.il-key-expanded {
    max-width: 100%;
    flex-wrap: wrap;
}

.il-copy-btn {
    background: #2a5bff;
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.il-copy-btn:hover {
    background: #1d4ed8;
}

/* Actions row beneath each licence */
.il-actions-row td {
    padding-top: 4px !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid #e5e7eb !important;
}

.il-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.il-status-active {
    background: #dcfce7;
    color: #166534;
}

.il-status-inactive {
    background: #fef3c7;
    color: #92400e;
}

.il-status-expired {
    background: #fef2f2;
    color: #991b1b;
}

/* Downloads */
.il-downloads-content {
    font-size: 14px;
    line-height: 1.7;
}

.il-downloads-content a {
    color: #2a5bff;
    text-decoration: none;
    font-weight: 500;
}

.il-downloads-content a:hover {
    text-decoration: underline;
    color: #1d4ed8;
}

.il-downloads-content ul,
.il-downloads-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.il-downloads-content li {
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.il-downloads-content li:last-child {
    border-bottom: none;
}

.il-downloads-content p {
    margin: 8px 0;
}

.il-download-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.il-download-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.il-download-list li:last-child {
    border-bottom: none;
}

/* Loading */
.il-loading {
    text-align: center;
    color: #888;
    padding: 20px;
}

.il-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #eee;
    border-top-color: #2a5bff;
    border-radius: 50%;
    animation: il-spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes il-spin {
    to { transform: rotate(360deg); }
}

/* Small Button Variant */
.il-button-small {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 5px;
}

/* Purchase Cards */
.il-purchase-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.il-purchase-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.il-purchase-card:hover {
    border-color: #2a5bff;
    box-shadow: 0 4px 12px rgba(42, 91, 255, 0.1);
}

.il-purchase-card h4 {
    margin: 0 0 8px;
    font-size: 17px;
    color: #222;
}

.il-purchase-card p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #666;
}

.il-purchase-price {
    font-size: 28px !important;
    font-weight: 700;
    color: #111 !important;
    margin-bottom: 4px !important;
}

/* Upgrade Buttons in Licence Table */
.il-licence-table .il-button-small {
    margin: 2px 4px 2px 0;
    white-space: nowrap;
}

.il-tier-max {
    display: inline-block;
    font-size: 12px;
    color: #166534;
    background: #dcfce7;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* AI Models Panel */
.il-ai-model-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.il-ai-model-info strong {
    font-size: 15px;
    color: #222;
}

.il-ai-model-info p {
    margin: 4px 0 0;
    font-size: 13px;
    color: #666;
}

/* ── Mobile Responsive ── */

@media (max-width: 768px) {
    .il-portal-container {
        margin: 16px auto;
        padding: 0 12px;
    }

    .il-portal-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 16px;
    }

    .il-portal-header h2 {
        font-size: 22px;
        text-align: center;
    }

    .il-portal-actions {
        justify-content: center;
    }

    .il-portal-actions .il-button {
        padding: 9px 16px;
        font-size: 14px;
    }

    .il-panel {
        padding: 16px;
        margin-bottom: 14px;
        border-radius: 8px;
    }

    .il-panel h3 {
        font-size: 16px;
    }

    /* Licence table → card layout on mobile */
    .il-licence-table thead {
        display: none;
    }

    .il-licence-table,
    .il-licence-table tbody,
    .il-licence-table tr,
    .il-licence-table td {
        display: block;
        width: 100%;
    }

    .il-licence-table tr {
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 0;
    }

    .il-licence-table tr + tr:not(.il-actions-row) {
        margin-top: 10px;
    }

    .il-licence-table .il-actions-row {
        border-top: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        padding-top: 0;
    }

    .il-licence-table .il-actions-row td {
        border-bottom: none !important;
    }

    .il-licence-table tr:has(+ .il-actions-row) {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        margin-bottom: 0;
        padding-bottom: 4px;
    }

    .il-licence-table td {
        padding: 4px 0;
        border-bottom: none;
        font-size: 14px;
    }

    .il-licence-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #555;
        margin-bottom: 2px;
    }

    .il-licence-key {
        max-width: 100%;
    }

    .il-licence-table .il-button-small {
        display: inline-block;
        margin: 4px 4px 4px 0;
    }

    /* Purchase cards */
    .il-purchase-cards {
        grid-template-columns: 1fr 1fr;
    }

    .il-purchase-price {
        font-size: 22px !important;
    }

    .il-purchase-card {
        padding: 14px;
    }

    /* AI models */
    .il-ai-model-card {
        flex-direction: column;
        text-align: center;
    }

    /* Auth page */
    .il-auth-container {
        margin: 20px auto;
        padding: 0 12px;
    }

    .il-auth-card {
        padding: 20px;
    }

    /* Serial form */
    .il-form-inline .il-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .il-purchase-cards {
        grid-template-columns: 1fr;
    }

    .il-portal-actions {
        flex-direction: column;
    }

    .il-portal-actions .il-button {
        width: 100%;
        text-align: center;
    }
}

/* Empty States */
.il-empty {
    text-align: center;
    color: #888;
    padding: 20px 0;
    font-size: 14px;
}
