/* style.css */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f8f8f8;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --heading-color: #111827;
    --danger: #ef4444;
    --success: #10b981;
    --pasta: #f5d731ce;
    --mpl: #3b5a97;
    --mpl-hover: #2e446d;
    --surface-border: #f6f6f6;
    --soft-surface: #f9fafb;
    --input-bg: #f6f6f6;
    --tooltip-bg: rgba(17, 24, 39, 0.95);
    --tooltip-text: #ffffff;
    --header-shadow: 1px 4px 0px -1px rgba(0, 0, 0, 0.1);
    --card-shadow: 1px 4px 0px -1px rgba(0, 0, 0, 0.1);
    --card-hover-shadow: 0 12px 6px -4px rgba(0, 0, 0, 0.1);
    --toggle-bg: rgba(255, 255, 255, 0.92);
    --toggle-border: rgba(209, 213, 219, 0.753);
    --toggle-color: #37568e;
    --toggle-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
    --focus-ring: rgba(59, 90, 151, 0.2);
    --muted-text: #6b7280;
    --modal-bg: rgba(255, 255, 255, 0.92);
    --modal-border: #e5e7eb;
    --modal-heading: #37568f;
    --input-border: #d1d5db;
    --input-border-focus: #d1d5db;
}

html[data-theme='dark'] {
    --bg-color: #23282e;
    --card-bg: #2c333f;
    --text-color: #e5edf8;
    --heading-color: #f8fafc;
    --surface-border: #22324b00;
    --soft-surface: #162235;
    --input-bg: #18273a;
    --tooltip-bg: rgba(248, 250, 252, 0.96);
    --tooltip-text: #0f172a;
    --header-shadow: 1px 4px 0px -1px rgba(0, 0, 0, 0.1);
    --card-shadow: 1px 4px 0px -1px rgba(0, 0, 0, 0.418);
    --card-hover-shadow: 0 12px 6px -4px rgba(0, 0, 0, 0.1);
    --toggle-bg: rgba(12, 20, 33, 0.96);
    --toggle-border: rgba(88, 104, 128, 0.9);
    --toggle-color: #f8fafc;
    --toggle-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    --focus-ring: rgba(96, 165, 250, 0.25);
    --muted-text: #9fb0c4;
    --modal-bg: rgba(15, 23, 42, 0.96);
    --modal-border: #2a3a55;
    --modal-heading: #f8fafc;
    --input-border: #314159;
    --input-border-focus: #6ea8fe;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 1rem;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    margin-bottom: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    padding: 0.7rem 1rem;
    border-radius: 15px;
    box-shadow: var(--header-shadow);
    border: 1px solid var(--surface-border);
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.logo {
    height: 45px;
}

h1 {
    font-family: Arial, Helvetica, sans-serif, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif, Times, serif;
    font-size: 1.6rem;
    color: var(--modal-heading);
}

.theme-toggle {
    position: fixed;
    right: clamp(1rem, calc((100vw - 1000px) / 2 + 1rem), 2rem);
    width: 56px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding: 2px;
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--card-bg);
    cursor: pointer;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    border: none;
    box-shadow: var(--card-shadow);
}

.theme-toggle.dark {
    justify-content: flex-end;
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring), var(--toggle-shadow);
}

.theme-toggle-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--toggle-color);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-top: 2px;
}

.theme-toggle-icon {
    font-size: 0.85rem;
    position: absolute;
    transition: opacity 0.3s ease;
}

.theme-toggle-icon.fa-moon {
    opacity: 1;
}

.theme-toggle-icon.fa-sun {
    opacity: 0;
}

.theme-toggle.dark .theme-toggle-icon.fa-moon {
    opacity: 0;
}

.theme-toggle.dark .theme-toggle-icon.fa-sun {
    opacity: 1;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--mpl);
    background: var(--soft-surface);
    color: var(--text-color);
    cursor: pointer;
    font-weight: bold;
}

.tab-btn:hover {
    background: var(--mpl-hover);
    color: #fff;
    border-color: var(--mpl-hover);
}

.tab-btn.active {
    background: var(--mpl);
    color: #fff;
    border-color: var(--mpl);
}

.tab-btn.active:hover {
    background: var(--mpl-hover);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background-color: var(--mpl); color: white; }
.btn-primary:hover { background-color: var(--mpl-hover); }
.btn-danger { background-color: var(--danger); color: white; width: 100px;}
.btn-danger:hover { background-color: #dc2626; }
.btn-outline { border: 1px solid var(--mpl); color: var(--mpl); width: 100px; background: transparent; margin-bottom: 10px;}
.btn-outline:hover { background-color: var(--mpl-hover); color: white; }

/* Form Styles (Admin) */
.forms-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.5rem;
    border: 1px solid var(--bg-color);
    box-shadow: 1px 4px 0px -1px rgba(0, 0, 0, 0.1);
}

.form-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

input {
    flex: 1;
    padding: 0.75rem;
    border-radius: 0.375rem;
    outline: none;
    background: var(--input-bg);
    color: var(--text-color);
    border: 0;
    transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

input:focus {
    border-color: var(--mpl);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="color"] {
    width: 80px;
    height: 45px;
    cursor: pointer;
    padding: 4px;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
}

input[type="color"]:hover {
    border-color: var(--mpl);
}

input[type="color"]:focus {
    border-color: var(--mpl);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

select {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
    background-color: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

select:focus {
    border-color: var(--mpl);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Table Styles (Admin) */
.table-container {
    background: var(--card-bg);
    border-radius: 0.5rem;
    overflow-y: hidden;
    box-shadow: 1px 4px 0px -1px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
    border: 2px solid var(--bg-color);
}

th {
    background-color: var(--mpl);
    font-weight: 600;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.url-cell {
    max-width: 260px;
    width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.url-cell a {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Grid Catalog Styles (Index) */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1.5rem;
}

.app-card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    width: 150px;
    height: 190px;
    z-index: 0;
    border: 1px solid var(--surface-border);
}

.app-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-hover-shadow);
    z-index: 10;
}

.app-icon {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 12px;
}

.icon-bg {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    margin-bottom: 0.75rem;
}

.app-name {
    font-weight: 600;
    text-align: center;
    font-size: 0.875rem;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

.app-card.draggable {
    cursor: grab;
}

.app-card.dragging {
    opacity: 0.6;
}

.star-favorite {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    cursor: pointer;
    z-index: 10;
    color: #fbbf24;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    user-select: none;
}

.star-favorite.visible {
    opacity: 1;
}

.star-favorite:hover {
    transform: translateX(-50%) scale(1.2);
}

.app-card:hover .star-favorite:not(.favorited) {
    opacity: 1;
}

.star-favorite.favorited {
    opacity: 1;
}

.app-description {
    font-size: 0.75rem;
    color: var(--muted-text);
    text-align: center;
    margin-top: 0.5rem;
    line-height: 1.3;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.app-tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: normal;
    max-width: 250px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-in-out;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.app-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--tooltip-bg);
}

.app-card:hover .app-tooltip {
    opacity: 1;
    transition-delay: 0.3s;
}

.folder-card {
    border: 2px dashed var(--pasta) !important;
    cursor: pointer;
}

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

.search-input {
    height: 40px;
    padding: 0.5rem 0.75rem;
    border-radius: 15px;
    outline: none;
    max-width: 350px;
    border: 0px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.search-input:focus {
    border: 1px solid var(--mpl);
}

#appBg, #folderBg {
    max-width: 80px !important;
    background-color: var(--card-bg) !important;
    padding: 0.2px 2px!important;
    height: 25px !important;
    border-radius: 0;
}

@media (max-width: 768px) {
    .theme-toggle {
        right: 0.8rem;
        width: 52px;
        height: 26px;
    }

    header {
        padding-right: 4.25rem;
    }
}

.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

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

#mainContainer {
    transition: filter 0.3s ease;
}

#mainContainer.blurred {
    filter: blur(5px);
    pointer-events: none;
}

.auth-modal-content {
    background: var(--modal-bg);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--modal-border);
}

.auth-modal-content img {
    max-width: 120px;
    height: auto;
    margin-bottom: 1.5rem;
}

.auth-modal-content h2 {
    margin: 0 0 1.5rem 0;
    color: var(--modal-heading);
    font-size: 1.5rem;
}

.auth-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid var(--input-border);
    border-radius: 0.5rem;
    text-align: center;
    letter-spacing: 2px;
    font-weight: bold;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.auth-input:focus {
    outline: none;
    border-color: var(--input-border-focus);
}

.auth-input.error {
    border-color: #ef4444;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Responsividade */
@media (max-width: 768px) {
    .forms-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .form-group {
        flex-direction: column;
    }
    
    input, select {
        width: 100%;
    }
}