/* =========================================================
   Signify Dev Cert Management — Admin Panel Stylesheet
   ========================================================= */

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:   #1e40af;   /* blue-800 */
    --color-primary-h: #1d4ed8;   /* blue-700 */
    --color-bg:        #f8fafc;
    --color-surface:   #ffffff;
    --color-border:    #e2e8f0;
    --color-text:      #1e293b;
    --color-muted:     #64748b;
    --color-danger:    #dc2626;
    --color-success:   #16a34a;
    --color-danger-bg: #fef2f2;
    --color-success-bg:#f0fdf4;
    --nav-height:      56px;
    --radius:          6px;
    --shadow:          0 1px 3px 0 rgb(0 0 0 / .10), 0 1px 2px -1px rgb(0 0 0 / .10);
}

html { font-size: 16px; }

body {
    font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .75rem; color: var(--color-text); }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .5rem; }

p { margin-bottom: .75rem; }
ul { margin: .5rem 0 .75rem 1.25rem; }
li { margin-bottom: .25rem; }

/* ---------- Navigation ---------- */
header {
    background: var(--color-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

header nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    letter-spacing: .02em;
    white-space: nowrap;
    margin-right: auto;
}

header nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: .25rem;
}

header nav ul li { margin: 0; }

header nav ul li a,
header nav ul li button {
    display: inline-block;
    padding: .35rem .8rem;
    border-radius: var(--radius);
    color: rgba(255,255,255,.85);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.6;
}

header nav ul li a:hover,
header nav ul li button:hover,
header nav ul li a.active {
    background: rgba(255,255,255,.18);
    color: #ffffff;
    text-decoration: none;
}

header nav ul li a.active { font-weight: 600; }

/* Logout form inline */
#logout-form { display: inline; }

/* ---------- Main content ---------- */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---------- Footer ---------- */
footer {
    text-align: center;
    padding: 1rem 1.5rem;
    color: var(--color-muted);
    font-size: .8rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* ---------- Alerts ---------- */
.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--color-success-bg);
    border-color: #bbf7d0;
    color: #15803d;
}

.alert-error {
    background: var(--color-danger-bg);
    border-color: #fecaca;
    color: var(--color-danger);
}

.alert ul { margin: .25rem 0 0 1rem; }
.alert li { margin-bottom: .1rem; }

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

thead { background: var(--color-primary); color: #fff; }
thead th { padding: .65rem 1rem; text-align: left; font-weight: 600; font-size: .85rem; letter-spacing: .03em; text-transform: uppercase; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: #eff6ff; }
td { padding: .6rem 1rem; border-bottom: 1px solid var(--color-border); color: var(--color-text); }

/* ---------- Login page ---------- */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 60%, #2563eb 100%);
}

.login-container {
    background: var(--color-surface);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgb(0 0 0 / .25);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: .25rem;
    text-align: center;
}

.login-container h2 {
    font-size: .95rem;
    font-weight: 500;
    color: var(--color-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

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

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

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"] {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.15);
}

.form-group input.is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

/* ---------- Buttons ---------- */
button[type="submit"],
.btn {
    display: inline-block;
    width: 100%;
    padding: .6rem 1.25rem;
    background: var(--color-primary);
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s;
    margin-top: .5rem;
}

button[type="submit"]:hover,
.btn:hover { background: var(--color-primary-h); }

/* Logout button — inline in nav, override width */
#logout-form button[type="submit"] {
    width: auto;
    margin-top: 0;
    padding: .35rem .8rem;
}

/* ---------- Pagination (Laravel default) ---------- */
nav[role="navigation"] { margin-top: 1rem; }

/* ---------- Page header (title + action button row) ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-header h1 { margin-bottom: 0; }

/* ---------- Card ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card h2 { margin-bottom: .75rem; }

/* ---------- Select ---------- */
.form-group select {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2.25rem;
    cursor: pointer;
}

.form-group select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.15);
}

.form-group select.is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

/* ---------- FQDN split input (label + static domain suffix) ---------- */
.fqdn-input-group {
    display: flex;
    align-items: stretch;
}

.fqdn-input-group input[type="text"] {
    flex: 1;
    min-width: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: 0;
}

.fqdn-input-group input[type="text"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.15);
    position: relative;
    z-index: 1;
}

.fqdn-input-group input[type="text"].is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

.fqdn-suffix {
    display: flex;
    align-items: center;
    padding: .55rem .75rem;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: .95rem;
    color: var(--color-muted);
    white-space: nowrap;
    user-select: none;
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
}

/* ---------- Form hints & errors ---------- */
.form-hint {
    display: block;
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .25rem;
}

.form-error {
    display: block;
    font-size: .8rem;
    color: var(--color-danger);
    margin-top: .25rem;
}

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

/* ---------- Buttons — width & variant additions ---------- */
.btn-auto { width: auto !important; }

.btn-sm {
    padding: .3rem .7rem !important;
    font-size: .82rem !important;
}

.btn-secondary {
    background: var(--color-muted) !important;
    color: #fff !important;
}
.btn-secondary:hover { background: #475569 !important; }

.btn-danger {
    background: var(--color-danger) !important;
    color: #fff !important;
}
.btn-danger:hover { background: #b91c1c !important; }

.btn-warning {
    background: #d97706 !important;
    color: #fff !important;
}
.btn-warning:hover { background: #b45309 !important; }

/* ---------- Status badges ---------- */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-lg {
    padding: .3rem .85rem;
    font-size: .85rem;
}

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-issuing  { background: #dbeafe; color: #1e40af; }
.badge-active   { background: #dcfce7; color: #166534; }
.badge-failed   { background: #fecaca; color: #991b1b; }
.badge-disabled { background: #f1f5f9; color: #475569; }
.badge-revoked  { background: #fee2e2; color: #7f1d1d; }
.badge-warning  { background: #fef3c7; color: #92400e; }

/* ---------- Detail list (dl/dt/dd) ---------- */
.detail-list {
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr;
    gap: .45rem .75rem;
    font-size: .9rem;
}

.detail-list dt {
    font-weight: 600;
    color: var(--color-muted);
    align-self: start;
    padding-top: .1rem;
}

.detail-list dd { color: var(--color-text); }

/* ---------- Action group ---------- */
.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-start;
}

/* ---------- Action details (disable form expand) ---------- */
.action-details > summary {
    cursor: pointer;
    list-style: none;
    display: inline-block;
}

.action-details > summary::-webkit-details-marker { display: none; }

.action-details-body {
    margin-top: .75rem;
    padding: 1rem;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    max-width: 480px;
}

/* ---------- Tab navigation ---------- */
.tab-nav {
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-x: auto;
    padding: 0 .25rem;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: .7rem 1.1rem;
    font-size: .9rem;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
    width: auto;
    margin-top: 0;
    border-radius: 0;
    font-family: inherit;
    line-height: 1.5;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--color-primary);
    background: rgba(30,64,175,.04);
    text-decoration: none;
}

.tab-btn[aria-selected="true"] {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.tab-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

/* ---------- Dashboard stat cards ---------- */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.5rem;
    min-width: 120px;
    text-align: center;
    border-top: 3px solid var(--color-border);
}

.stat-card.stat-active  { border-top-color: #16a34a; }
.stat-card.stat-pending { border-top-color: #d97706; }
.stat-card.stat-disabled{ border-top-color: #64748b; }
.stat-card.stat-revoked { border-top-color: var(--color-danger); }

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

.stat-label {
    font-size: .78rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: .35rem;
}
