/* ==========================================================================
   Variables & Base Styles
   ========================================================================== */
:root {
    --primary-color: #0052cc;
    --primary-hover: #0047b3;
    --bg-color: #f4f5f7;
    --card-bg: #ffffff;
    --text-main: #172b4d;
    --text-muted: #5e6c84;
    --border-color: #dfe1e6;
    --error-color: #de350b;
    --success-color: #00875a;
    --border-radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 16px; /* Good for mobile readability */
}

/* ==========================================================================
   Layout & Screens
   ========================================================================== */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    background: var(--card-bg);
    padding: 30px 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.login-container .subtitle {
    color: var(--text-muted);
    margin-bottom: 25px;
    font-size: 14px;
}

/* Main App */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h2 {
    font-size: 18px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

main {
    flex: 1;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================================================
   Components (Buttons, Forms, etc.)
   ========================================================================== */
button {
    cursor: pointer;
    border: none;
    font-size: 16px;
    font-weight: 500;
    border-radius: 4px;
    padding: 10px 16px;
    transition: background-color 0.2s;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

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

.secondary-btn {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background-color: #f4f5f7;
}

.text-btn {
    background: none;
    color: white;
    padding: 0;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .half {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px; /* Prevents iOS zoom */
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.2);
}

.error-msg {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 10px;
}

/* ==========================================================================
   Search & Results
   ========================================================================== */
.search-section {
    margin-bottom: 20px;
}

.search-bar {
    display: flex;
    gap: 10px;
}

.search-bar input {
    flex: 1;
}

.search-bar button {
    width: auto;
}

.admin-panel {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.admin-panel button {
    flex: 1;
}

.results-area {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    min-height: 200px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.placeholder-state {
    color: var(--text-muted);
    text-align: center;
    padding-top: 40px;
}

/* ==========================================================================
   Admin Form View
   ========================================================================== */
.form-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.form-header .text-btn {
    color: var(--primary-color);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.form-actions button {
    flex: 1;
}

/* ==========================================================================
   Overlays & Loading
   ========================================================================== */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}