* {
    box-sizing: border-box;
}

:root {
    --bg: #f8fafd;
    --surface: #ffffff;
    --surface-2: #f1f3f4;
    --text: #202124;
    --muted: #5f6368;
    --line: #dadce0;
    --blue: #1a73e8;
    --blue-dark: #0b57d0;
    --blue-soft: #e8f0fe;
    --danger: #d93025;
    --green: #188038;
    --folder: #fbbc04;
    --shadow: 0 1px 2px rgba(60,64,67,.15), 0 1px 3px 1px rgba(60,64,67,.08);
    --shadow-hover: 0 4px 10px rgba(60,64,67,.18);
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* Login */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f0fe, #ffffff);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 24px;
    padding: 36px;
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--line);
}

.login-card h1 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 28px;
}

.login-card p {
    margin: 0 0 24px;
    color: var(--muted);
}

.input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    font-size: 15px;
    background: #fff;
}

.input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}

textarea {
    min-height: 90px;
    resize: vertical;
}

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

.btn, .btn-drive {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    background: #fff;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
}

.btn:hover, .btn-drive:hover {
    background: var(--surface-2);
    box-shadow: var(--shadow);
}

.btn-secundario {
    background: #fff;
    color: var(--text);
}

.btn-drive.primary, .btn:not(.btn-secundario) {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.btn-drive.primary:hover, .btn:not(.btn-secundario):hover {
    background: var(--blue-dark);
}

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

.alerta {
    padding: 12px 16px;
    border-radius: 12px;
    margin: 12px 0 18px;
    background: #fef7e0;
    color: #8a4b00;
    border: 1px solid #fdd663;
}

.alerta-ok {
    background: #e6f4ea;
    color: #137333;
    border-color: #ceead6;
}

/* Layout estilo Google Drive */
.layout {
    display: flex;
    min-height: 100vh;
}

.drive-sidebar, .sidebar {
    width: 270px;
    min-width: 270px;
    background: #fff;
    color: var(--text);
    border-right: 1px solid #edf0f2;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 12px;
    margin-bottom: 12px;
    font-size: 21px;
    color: #3c4043;
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4285f4, #34a853 55%, #fbbc04 56%, #ea4335);
    color: transparent;
    display: inline-block;
}

.sidebar h2 {
    margin: 0 0 20px;
    font-size: 22px;
    color: var(--text);
}

.create-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 118px;
    height: 56px;
    border-radius: 18px;
    margin: 6px 0 20px 8px;
    padding: 0 22px;
    background: #fff;
    color: #3c4043;
    box-shadow: var(--shadow);
    font-size: 16px;
    font-weight: 600;
}

.create-button:hover {
    background: #f8fafd;
    box-shadow: var(--shadow-hover);
}

.side-nav a, .sidebar > a:not(.brand):not(.create-button) {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 42px;
    padding: 0 16px;
    border-radius: 0 22px 22px 0;
    margin: 2px 0;
    color: #3c4043;
    font-size: 14px;
}

.side-nav a:hover, .sidebar > a:not(.brand):not(.create-button):hover {
    background: #f1f3f4;
}

.side-nav a.active {
    background: #e8f0fe;
    color: #1967d2;
    font-weight: 700;
}

.contenido {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

.drive-page {
    padding: 0;
    background: var(--bg);
}

.drive-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 28px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 20;
}

.drive-search {
    flex: 1;
    max-width: 720px;
    height: 48px;
    border-radius: 24px;
    background: #edf2fa;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    transition: .18s ease;
}

.drive-search:focus-within {
    background: #fff;
    box-shadow: var(--shadow);
}

.search-icon {
    color: var(--muted);
    font-size: 16px;
}

.drive-search input {
    border: 0;
    outline: none;
    flex: 1;
    height: 100%;
    background: transparent;
    font-size: 15px;
    color: var(--text);
}

.drive-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.drive-user-chip strong {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.drive-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 32px 8px;
}

.drive-toolbar h1 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 500;
    color: var(--text);
}

.drive-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.drive-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 14px;
}

.drive-breadcrumb a {
    color: var(--blue-dark);
    padding: 4px 8px;
    border-radius: 10px;
}

.drive-breadcrumb a:hover {
    background: var(--blue-soft);
}

.new-menu {
    position: relative;
}

.new-menu summary {
    list-style: none;
    cursor: pointer;
    height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--blue);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.new-menu summary::-webkit-details-marker,
.card-menu summary::-webkit-details-marker,
.tile-menu summary::-webkit-details-marker {
    display: none;
}

.new-menu-box, .card-menu-box, .tile-menu-box {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 230px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-hover);
    padding: 8px;
    z-index: 50;
}

.new-menu-box a, .card-menu-box a, .tile-menu-box a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
}

.new-menu-box a:hover, .card-menu-box a:hover, .tile-menu-box a:hover {
    background: #f1f3f4;
}

.danger-link {
    color: var(--danger) !important;
}

.drive-section-title {
    margin: 24px 32px 12px;
    color: #3c4043;
    font-size: 16px;
    font-weight: 600;
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    padding: 0 32px 8px;
}

.gdrive-folder {
    height: 54px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: visible;
    position: relative;
}

.gdrive-folder:hover {
    background: #f8fafd;
    box-shadow: var(--shadow);
}

.folder-open {
    min-width: 0;
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 0 16px;
}

.folder-material {
    font-size: 23px;
    line-height: 1;
}

.folder-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: var(--text);
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
    padding: 0 32px 40px;
}

.gdrive-file {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: visible;
    position: relative;
    min-height: 210px;
    transition: .15s ease;
}

.gdrive-file:hover {
    box-shadow: var(--shadow);
    border-color: #cdd3d8;
}

.file-open {
    display: block;
    color: var(--text);
}

.file-preview {
    height: 154px;
    margin: 10px;
    border-radius: 12px;
    background: #f1f3f4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.file-info {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 42px 0 14px;
}

.file-info strong {
    min-width: 0;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
}

.file-type-dot {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: #9aa0a6;
    display: inline-block;
    flex: 0 0 18px;
}

.file-type-dot.type-pdf { background: #ea4335; }
.file-type-dot.type-word { background: #4285f4; }
.file-type-dot.type-excel { background: #34a853; }
.file-type-dot.type-ppt { background: #fbbc04; }
.file-type-dot.type-zip { background: #a142f4; }
.file-type-dot.type-js, .file-type-dot.type-code { background: #5f6368; }

.google-file-icon {
    width: 82px;
    height: 104px;
    background: #fff;
    border: 1px solid #c7cbd1;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    box-shadow: inset 0 -44px 0 #9aa0a6;
}

.google-file-icon:before {
    content: "";
    position: absolute;
    top: -1px;
    right: -1px;
    width: 27px;
    height: 27px;
    background: linear-gradient(135deg, #e8eaed 0 50%, transparent 50%);
    border-left: 1px solid #c7cbd1;
    border-bottom: 1px solid #c7cbd1;
}

.google-file-icon span {
    position: relative;
    z-index: 1;
    color: #fff;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: .5px;
    padding-bottom: 11px;
}

.google-file-icon.type-pdf { box-shadow: inset 0 -44px 0 #ea4335; }
.google-file-icon.type-word { box-shadow: inset 0 -44px 0 #4285f4; }
.google-file-icon.type-excel { box-shadow: inset 0 -44px 0 #34a853; }
.google-file-icon.type-ppt { box-shadow: inset 0 -44px 0 #fbbc04; }
.google-file-icon.type-zip { box-shadow: inset 0 -44px 0 #a142f4; }
.google-file-icon.type-js, .google-file-icon.type-code { box-shadow: inset 0 -44px 0 #5f6368; }

.card-menu, .tile-menu {
    position: absolute;
    right: 8px;
    top: 8px;
}

.gdrive-folder .card-menu {
    top: 7px;
    right: 7px;
}

.card-menu summary, .tile-menu summary {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: var(--muted);
}

.card-menu summary:hover, .tile-menu summary:hover {
    background: #eef0f2;
}

.file-card-menu {
    top: auto;
    bottom: 4px;
}

.file-card-menu .card-menu-box {
    top: auto;
    bottom: calc(100% + 8px);
}

.drive-empty, .empty-drive {
    margin: 36px 32px;
    padding: 48px 24px;
    border-radius: 20px;
    border: 1px dashed #c7cbd1;
    background: #fff;
    text-align: center;
    color: var(--muted);
}

.drive-empty h2, .empty-drive h2 {
    margin: 10px 0 8px;
    color: #3c4043;
    font-size: 22px;
    font-weight: 500;
}

.drive-empty p, .empty-drive p {
    margin: 0;
}

.empty-icon {
    font-size: 48px;
}

/* Compatibilidad con versiones anteriores */
.header-card, .card {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    border: 1px solid var(--line);
}

.header-card h1 {
    margin: 0 0 8px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.stat {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.stat h3 {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

.stat p {
    margin: 10px 0 0;
    font-size: 34px;
    font-weight: bold;
    color: var(--blue);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.table th, .table td {
    padding: 14px;
    border-bottom: 1px solid #edf0f2;
    text-align: left;
    font-size: 14px;
}

.table th {
    background: #f8fafd;
    color: #3c4043;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue-dark);
    font-size: 12px;
    font-weight: 700;
}

.section-title {
    margin: 20px 0 14px;
    font-size: 18px;
}

.explorer-grid, .item-tile, .folder-icon-big, .file-icon-big, .image-thumb {
    /* Mantiene visibles las pantallas antiguas, pero el diseño nuevo usa gdrive-folder/gdrive-file. */
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .drive-sidebar, .sidebar {
        width: 100%;
        min-width: 0;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid #edf0f2;
    }

    .side-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
    }

    .side-nav a {
        border-radius: 999px;
        white-space: nowrap;
        min-width: max-content;
    }

    .create-button {
        height: 46px;
        margin: 8px 0 12px;
    }

    .drive-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .drive-user-chip {
        display: none;
    }

    .drive-toolbar {
        padding: 14px 16px 8px;
        flex-direction: column;
    }

    .drive-actions {
        justify-content: flex-start;
    }

    .folder-grid, .file-grid {
        padding-left: 16px;
        padding-right: 16px;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .drive-section-title {
        margin-left: 16px;
        margin-right: 16px;
    }
}
