/* ============================================================
   Future Energy Solution Portal - Global Styles
   Brand: Azul Cielo #3FACD5 | Verde #3B8A3E | Lima #A0C844
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@300;400;500&display=swap');

/* ---- CSS Variables ---- */
:root {
    --color-primary: #3FACD5;
    --color-primary-dark: #2d8fb3;
    --color-primary-light: #5fc0e2;
    --color-secondary: #3B8A3E;
    --color-secondary-dark: #2d6b2f;
    --color-accent: #A0C844;
    --color-accent-light: #b5d66a;

    --bg-darkest: #0c1117;
    --bg-dark: #111820;
    --bg-medium: #182028;
    --bg-card: #1c2530;
    --bg-card-hover: #222e3a;
    --bg-input: #151d26;

    --text-primary: #e8edf2;
    --text-secondary: #8899aa;
    --text-muted: #5a6a7a;

    --border-color: #2a3545;
    --border-light: #344050;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(63, 172, 213, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --font-serif: 'Instrument Serif', Georgia, serif;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-darkest);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-light);
}

/* ---- Background Pattern ---- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(63, 172, 213, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 138, 62, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(160, 200, 68, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ---- Login Page ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary), var(--color-accent));
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.login-logo img {
    height: 64px;
    width: auto;
}

.login-logo .logo-text {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
}

.login-logo .logo-text span {
    color: var(--color-primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
    font-weight: 400;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-group input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(63, 172, 213, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    width: 100%;
    padding: 14px 24px;
    font-size: 0.95rem;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
    box-shadow: 0 4px 15px rgba(63, 172, 213, 0.3);
    transform: translateY(-1px);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.btn-danger {
    background: #c0392b;
    color: #fff;
}

.btn-danger:hover {
    background: #e74c3c;
    color: #fff;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.82rem;
}

.btn-accent {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-dark));
    color: #fff;
}

.btn-accent:hover {
    background: linear-gradient(135deg, var(--color-accent), var(--color-secondary));
    box-shadow: 0 4px 15px rgba(59, 138, 62, 0.3);
    color: #fff;
}

/* ---- Alert Messages ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 20px;
    border: 1px solid;
}

.alert-error {
    background: rgba(192, 57, 43, 0.15);
    border-color: rgba(192, 57, 43, 0.3);
    color: #e74c3c;
}

.alert-success {
    background: rgba(59, 138, 62, 0.15);
    border-color: rgba(59, 138, 62, 0.3);
    color: var(--color-accent);
}

.alert-info {
    background: rgba(63, 172, 213, 0.1);
    border-color: rgba(63, 172, 213, 0.25);
    color: var(--color-primary-light);
}

/* ---- Header/Navbar ---- */
.navbar {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand img {
    height: 36px;
    width: auto;
}

.navbar-brand .brand-name {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    color: var(--text-primary);
}

.navbar-brand .brand-name span {
    color: var(--color-primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.navbar-user .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}

.navbar-user .user-name {
    color: var(--text-primary);
    font-weight: 500;
}

.navbar-user .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-logout:hover {
    border-color: #c0392b;
    color: #e74c3c;
    background: rgba(192, 57, 43, 0.1);
}

/* ---- Dashboard ---- */
.dashboard {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 32px;
}

.dashboard-header {
    margin-bottom: 40px;
}

.dashboard-header h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.dashboard-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ---- Tool Cards Grid ---- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.tool-card:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 20px;
    position: relative;
}

.tool-card-icon.icon-map {
    background: rgba(63, 172, 213, 0.12);
    color: var(--color-primary);
}

.tool-card-icon.icon-finance {
    background: rgba(59, 138, 62, 0.12);
    color: var(--color-secondary);
}

.tool-card-icon.icon-coming {
    background: rgba(160, 200, 68, 0.1);
    color: var(--color-accent);
}

.tool-card-icon.icon-admin {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.tool-card h3 {
    font-family: var(--font-sans);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tool-card p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
    margin-bottom: 24px;
    flex-grow: 1;
}

.tool-card .tool-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.tool-tag.tag-active {
    background: rgba(59, 138, 62, 0.15);
    color: var(--color-accent);
}

.tool-tag.tag-coming {
    background: rgba(160, 200, 68, 0.1);
    color: var(--color-accent);
    opacity: 0.7;
}

.tool-card .btn {
    margin-top: auto;
}

.tool-card.card-coming {
    opacity: 0.6;
    border-style: dashed;
}

.tool-card.card-coming:hover {
    opacity: 0.75;
    transform: none;
    box-shadow: none;
}

/* ---- Admin Panel ---- */
.admin-section {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 32px;
}

.admin-section h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 8px;
}

.admin-section > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
}

.admin-card h2 {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- Users Table ---- */
.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
}

.users-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.users-table td {
    color: var(--text-primary);
}

.users-table tr:last-child td {
    border-bottom: none;
}

.users-table .role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.role-admin {
    background: rgba(63, 172, 213, 0.15);
    color: var(--color-primary);
}

.role-badge.role-user {
    background: rgba(160, 200, 68, 0.1);
    color: var(--color-accent);
}

.users-table .actions {
    display: flex;
    gap: 8px;
}

/* ---- Create User Form ---- */
.create-user-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.create-user-form .form-group.full-width {
    grid-column: 1 / -1;
}

.create-user-form select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238899aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.create-user-form select:focus {
    border-color: var(--color-primary);
}

.create-user-form select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* ---- Tool Viewer ---- */
.tool-viewer {
    position: relative;
    z-index: 1;
}

.tool-viewer-header {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.tool-viewer-header .btn-back {
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.tool-viewer-header .btn-back:hover {
    color: var(--color-primary);
}

.tool-viewer-header h2 {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.tool-viewer iframe {
    width: 100%;
    height: calc(100vh - 64px - 52px);
    border: none;
    background: #fff;
}

/* ---- Setup Page ---- */
.setup-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.setup-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.setup-card h1 {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    margin-bottom: 8px;
    text-align: center;
}

.setup-card > p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    font-size: 0.9rem;
}

.setup-steps {
    list-style: none;
    margin-bottom: 24px;
}

.setup-steps li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.setup-steps li:last-child {
    border-bottom: none;
}

.setup-steps .step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.step-icon.done {
    background: rgba(59, 138, 62, 0.2);
    color: var(--color-accent);
}

.step-icon.pending {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.step-icon.error {
    background: rgba(192, 57, 43, 0.2);
    color: #e74c3c;
}

/* ---- Password Toggle ---- */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.1rem;
    transition: color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--text-secondary);
}

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 40px;
}

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

.footer a:hover {
    color: var(--color-primary);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
    }

    .navbar-brand .brand-name {
        font-size: 1.1rem;
    }

    .navbar-user .user-details {
        display: none;
    }

    .dashboard {
        padding: 24px 16px;
    }

    .dashboard-header h1 {
        font-size: 1.6rem;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 36px 28px;
    }

    .admin-section {
        padding: 24px 16px;
    }

    .create-user-form {
        grid-template-columns: 1fr;
    }

    .users-table {
        font-size: 0.82rem;
    }

    .users-table th,
    .users-table td {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    .navbar-right {
        gap: 10px;
    }

    .tool-card {
        padding: 24px;
    }
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.tools-grid .tool-card:nth-child(1) { animation-delay: 0.05s; }
.tools-grid .tool-card:nth-child(2) { animation-delay: 0.1s; }
.tools-grid .tool-card:nth-child(3) { animation-delay: 0.15s; }
.tools-grid .tool-card:nth-child(4) { animation-delay: 0.2s; }
