/* ============================================================
   FREIRAUM LICENSE SERVER - Admin CSS
   No external fonts, no CDN dependencies
   ============================================================ */

:root {
    --primary:       #2563EB;
    --primary-hover: #1D4ED8;
    --primary-soft:  #EFF6FF;
    --primary-text:  #1E40AF;

    --bg:            #F1F5F9;
    --surface:       #FFFFFF;
    --border:        #E2E8F0;
    --border-strong: #CBD5E1;

    --text:          #0F172A;
    --text-muted:    #64748B;
    --text-subtle:   #94A3B8;

    --success:       #16A34A;
    --success-soft:  #F0FDF4;
    --warning:       #D97706;
    --warning-soft:  #FFFBEB;
    --error:         #DC2626;
    --error-soft:    #FEF2F2;
    --info:          #0284C7;
    --info-soft:     #F0F9FF;

    --sidebar-width: 220px;
    --topbar-height: 56px;

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.08);

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

    /* Plan badge colors */
    --plan-free:             #64748B;
    --plan-starter:          #0891B2;
    --plan-pro:              #7C3AED;
    --plan-business:         #B45309;
}

/* ============================================================
   RESET & BASE
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; }

body {
    font-family: var(--font);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.375rem;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand .brand-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
}

.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    padding: 0.5rem 1.25rem 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0;
    transition: background 0.1s, color 0.1s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-item .nav-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header-left h1 {
    color: var(--text);
    margin-bottom: 0.25rem;
}

.page-header-left p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ============================================================
   STATS GRID
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    background: var(--bg);
    padding: 0.625rem 0.875rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg);
}

tbody td {
    padding: 0.75rem 0.875rem;
    color: var(--text);
    vertical-align: middle;
}

tbody td .text-muted {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s, border-color 0.1s, color 0.1s, opacity 0.1s;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm {
    padding: 0.3125rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-xs {
    padding: 0.1875rem 0.5rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
    background: var(--error);
    color: white;
    border-color: var(--error);
}
.btn-danger:hover { opacity: 0.9; }

.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-gray    { background: #F1F5F9; color: var(--text-muted); }
.badge-green   { background: var(--success-soft); color: var(--success); }
.badge-red     { background: var(--error-soft); color: var(--error); }
.badge-yellow  { background: var(--warning-soft); color: var(--warning); }
.badge-blue    { background: var(--primary-soft); color: var(--primary-text); }
.badge-purple  { background: #F5F3FF; color: #7C3AED; }
.badge-cyan    { background: #ECFEFF; color: #0891B2; }
.badge-amber   { background: #FFFBEB; color: #B45309; }

/* Plan badges */
.badge-plan-free            { background: #F1F5F9; color: #475569; }
.badge-plan-starter         { background: #ECFEFF; color: #0891B2; }
.badge-plan-pro             { background: #F5F3FF; color: #7C3AED; }
.badge-plan-business        { background: #FFFBEB; color: #B45309; }

/* Status badges */
.badge-active   { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--error-soft); color: var(--error); }
.badge-expired  { background: var(--warning-soft); color: var(--warning); }

/* Release status */
.badge-draft    { background: #F1F5F9; color: #475569; }
.badge-beta     { background: var(--warning-soft); color: var(--warning); }
.badge-stable   { background: var(--success-soft); color: var(--success); }
.badge-archived { background: #F1F5F9; color: var(--text-subtle); }

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.form-label .required {
    color: var(--error);
    margin-left: 0.25rem;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    line-height: 1.5;
    transition: border-color 0.1s, box-shadow 0.1s;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.25rem;
    padding-right: 2.25rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-error {
    font-size: 0.8125rem;
    color: var(--error);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */

.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.flash-success {
    background: var(--success-soft);
    border: 1px solid #86EFAC;
    color: #14532D;
}

.flash-error {
    background: var(--error-soft);
    border: 1px solid #FCA5A5;
    color: #7F1D1D;
}

.flash-warning {
    background: var(--warning-soft);
    border: 1px solid #FCD34D;
    color: #78350F;
}

.flash-info {
    background: var(--info-soft);
    border: 1px solid #7DD3FC;
    color: #0C4A6E;
}

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.25rem;
    flex-shrink: 0;
}
.flash-close:hover { opacity: 1; }

/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-right: auto;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background 0.1s, color 0.1s;
}

.page-link:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

.page-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================================
   FILTER BAR
   ============================================================ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    width: auto;
    min-width: 160px;
}

.filter-bar .search-input {
    min-width: 240px;
}

/* ============================================================
   LICENSE KEY DISPLAY
   ============================================================ */

.license-key {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.075em;
    color: var(--text);
    background: var(--bg);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: inline-block;
}

.license-key-small {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.1s;
}
.copy-btn:hover {
    background: var(--bg);
    color: var(--text);
}
.copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

/* ============================================================
   AUTH PAGE
   ============================================================ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 1.5rem;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}

.auth-card .brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-card .brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.auth-card .brand-sub {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================================
   DETAIL SECTIONS
   ============================================================ */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

.info-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 120px;
}

.info-value {
    font-size: 0.875rem;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 0.375rem;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ============================================================
   TOOLTIP
   ============================================================ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    background: #0F172A;
    color: white;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-muted  { color: var(--text-muted) !important; }
.text-subtle { color: var(--text-subtle) !important; }
.text-success { color: var(--success) !important; }
.text-error   { color: var(--error) !important; }
.text-warning { color: var(--warning) !important; }

.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }

.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
        width: 240px;
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
    }
}

/* ============================================================
   INSTALL PAGE
   ============================================================ */

.install-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 2rem 1rem;
}

.install-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-md);
}

.install-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.install-step {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.install-step.done {
    background: var(--success);
}

.install-step.active {
    background: var(--primary);
}

/* ============================================================
   BULK KEY LIST
   ============================================================ */

.key-list {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    max-height: 300px;
    overflow-y: auto;
    line-height: 2;
}

/* ============================================================
   CHANGELOG EDITOR
   ============================================================ */

.changelog-editor {
    min-height: 200px;
}

/* ============================================================
   RELEASE UPLOAD
   ============================================================ */

.upload-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-zone-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.upload-zone p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.upload-zone strong {
    color: var(--primary);
}
