:root {
    --primary-color: #007bff;
    --secondary-color: #28a745;
    --error-color: #d9534f;
    --text-muted: #666;
    --bg-color: #f4f7f6;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --input-radius: 4px;
}

/* 1. Global Layout */
html {
		background-color: var(--bg-color);
    visibility: visible !important;
    opacity: 1 !important;
    transition: opacity 0.2s ease-in;
		/* Prevents flicker during transitions in Firefox mobile */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: var(--bg-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

body.dashboard-page {
    display: block;
    padding: 0;
}

#content {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.links {
    text-align: center;
    margin-top: 1.5rem;
    display: block; /* Ensures it stays on its own line */
    width: 100%;
}

.links a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.2s, text-decoration 0.2s;
}

.links a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* Specific styling for the "Back" links with arrows */
.links a:contains("←") {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* 2. Cards */
.card, .login-card {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--card-shadow);
    box-sizing: border-box;
    margin-bottom: 20px;
}

#content .card {
    max-width: 100%;
}

/* 3. Unified Button System */
.btn, .pw-btn, .logout-btn {
    position: relative; /* Anchor for spinner */
    background: var(--primary-color);
    color: white !important;
    border: none;
    height: 44px;
    padding: 0 25px;
    border-radius: var(--input-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    min-width: 140px;
    box-sizing: border-box;
    text-decoration: none;
}

.logout-btn {
    height: 40px;        /* Slightly shorter than standard buttons */
    margin: 0;
}

.btn:hover { filter: brightness(90%); }
.btn:disabled { background: #ccc; cursor: not-allowed; }

/* Full-width override for Auth pages */
.login-card .btn { width: 100%; margin-top: 10px; }

/* Button Variants */
#updateBtn { background: var(--secondary-color); }
.btn-secondary { background: #6c757d !important; }

.logout-btn {
    background: #fff !important;
    color: var(--error-color) !important;
    border: 1.5px solid var(--error-color);
    height: 38px;
    min-width: auto;
}
.logout-btn:hover { background: var(--error-color) !important; color: #fff !important; }

/* 4. Spinner Logic (Non-disruptive) */
.spinner {
    position: absolute;
    left: 15px;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}

.loading .spinner { opacity: 1; visibility: visible; }
.loading .btn-text { transform: translateX(12px); } /* Shifts text slightly to make room */
.btn-text { transition: transform 0.2s; }

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

/* 5. Dashboard Header & Animations */
#header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0 2rem;
		height: 70px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}

#header-container h2 {
    margin: 0;
    line-height: 1;
    font-size: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Use this class for the smooth slide-in */
.form-actions.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 6. Forms & Utilities */
h2 { margin-top: 0; color: #333; text-align: center; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1.2rem; }
label { display: block; font-weight: bold; font-size: 0.9rem; margin-bottom: 0.5rem; color: #444; }

input {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: var(--input-radius);
    background: white;
    font-size: 1rem;
}

.hidden { display: none !important; }
.info { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.match-error { color: var(--error-color); font-size: 0.8rem; display: none; margin-top: 4px; }
.grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.error {
    color: var(--error-color);
    background: #fdf2f2;      /* The highlight box color */
    border: 1px solid #f8d7da; /* The border */
    padding: 12px;            /* Space inside the box */
    border-radius: var(--input-radius);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    text-align: center;
    box-sizing: border-box;
    display: none;            /* Hidden by default */
}

/* Dashboard Product Grid Styles */
.product-block {
    border: 1px solid #e0e6ed;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
    background: #fff;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.product-header:hover {
    background: #f1f5f9;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* The 3-column grid for licenses */
.license-grid {
    display: grid;
    grid-template-columns: 100px 180px 1fr; /* ID, Code, Description */
    gap: 10px;
    padding: 10px 15px;
    border-top: 1px solid #f1f5f9;
    align-items: center;
    font-size: 0.9rem;
}

.grid-header {
    font-weight: bold;
    background: #fcfdfe;
    color: #475569;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
		text-align: center;
}

.bold-code {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    letter-spacing: 1px;
    color: #1e293b;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
}

.description-text {
    color: var(--text-muted);
}

/* Character Colorizer styles */
.char-cap { color: #007bff; font-weight: bold; }
.char-low { color: #28a745; }
.char-num { color: #d9534f; font-weight: bold; }

@media (max-width: 600px) {
    .license-grid {
        grid-template-columns: 1fr; /* Stack columns on small screens */
        gap: 5px;
    }
    .grid-header { display: none; } /* Hide headers on mobile stack */
}

/* ===== MODAL (scoped, safe) ===== */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.modal-overlay.active {
	opacity: 1;
}

.modal-overlay.hidden {
	display: none;
}

.modal-box {
	transform: scale(0.95);
	transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
	transform: scale(1);
}

/* error text */
.modal-error {
	color: #d9534f;
	margin-bottom: 10px;
	font-size: 0.9em;
}

/* ===== TOAST ===== */
.toast {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%) translateY(20px);
	background: #333;
	color: #fff;
	padding: 10px 18px;
	border-radius: 6px;
	font-size: 0.9em;
	opacity: 0;
	transition: all 0.3s ease;
	z-index: 1100;
}

.toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

