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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    background: #2d2d2d;
    padding: 10px;
    display: flex;
    gap: 20px;
    border-bottom: 1px solid #3d3d3d;
    flex-shrink: 0;
}

.toolbar-section {
    display: flex;
    gap: 5px;
}

.tool-btn {
    background: #3d3d3d;
    color: #e0e0e0;
    border: 1px solid #4d4d4d;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 32px;
    min-height: 32px;
}

.tool-btn:hover {
    background: #4d4d4d;
    border-color: #5d5d5d;
}

.tool-btn.active {
    background: #0066cc;
    border-color: #0077ee;
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Tab Bar */
.tab-bar {
    background: #252525;
    border-bottom: 1px solid #3d3d3d;
    display: flex;
    padding: 0 10px;
    gap: 2px;
    overflow-x: auto;
    flex-shrink: 0;
}

.tab {
    background: #2d2d2d;
    border: 1px solid #3d3d3d;
    border-bottom: none;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    max-width: 200px;
    border-radius: 4px 4px 0 0;
    margin-top: 2px;
    transition: all 0.2s;
}

.tab:hover {
    background: #3d3d3d;
}

.tab.active {
    background: #1e1e1e;
    border-color: #0066cc;
    border-bottom: 1px solid #1e1e1e;
    margin-top: 0;
    padding-top: 10px;
}

.tab-name {
    flex: 1;
    font-size: 13px;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s;
}

.tab-close:hover {
    background: #d32f2f;
    color: white;
}

.tab.start-tab .tab-close {
    display: none;
}

/* Start Screen */
.start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
}

.start-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
}

.start-content h1 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #e0e0e0;
}

.start-content p {
    font-size: 16px;
    color: #b0b0b0;
    margin-bottom: 40px;
}

.start-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.start-btn {
    background: #2d2d2d;
    border: 2px solid #4d4d4d;
    padding: 20px 30px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
    color: #e0e0e0;
    min-width: 200px;
}

.start-btn:hover {
    background: #3d3d3d;
    border-color: #0066cc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.start-btn span {
    font-size: 32px;
}

.start-btn div {
    text-align: left;
}

.start-btn strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

.start-btn small {
    display: block;
    font-size: 12px;
    color: #888;
}

/* Sidebars */
.sidebar {
    background: #252525;
    padding: 15px;
    overflow-y: auto;
    border-right: 1px solid #3d3d3d;
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    padding: 15px 5px;
}

.left-sidebar {
    width: 200px;
}

.left-sidebar.collapsed {
    width: 40px;
}

.right-sidebar {
    width: 250px;
    border-right: none;
    border-left: 1px solid #3d3d3d;
}

.right-sidebar.collapsed {
    width: 40px;
}

.sidebar.collapsed > *:not(.collapse-toggle) {
    display: none;
}

.collapse-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #3d3d3d;
    border: 1px solid #4d4d4d;
    color: #e0e0e0;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    z-index: 10;
    transition: all 0.2s;
}

/* Rotate arrow icon when sidebar is collapsed */
.sidebar.collapsed .collapse-toggle {
    right: 5px;
    transform: rotate(180deg);
}

.collapse-toggle:hover {
    background: #4d4d4d;
}

.sidebar h3 {
    font-size: 14px;
    margin: 15px 0 10px 0;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar h3:first-child {
    margin-top: 0;
}

/* Panel Sections */
.panel-section {
    margin-bottom: 5px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #2d2d2d;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    margin: 5px 0;
}

.panel-header:hover {
    background: #353535;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-toggle {
    font-size: 10px;
    color: #888;
    transition: transform 0.2s;
}

.panel-section.collapsed .panel-toggle {
    transform: rotate(-90deg);
}

.panel-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    padding: 5px 0;
}

.panel-section.collapsed .panel-content {
    max-height: 0;
    opacity: 0;
    padding: 0;
}

/* Tool Groups */
.tool-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.tool-group .tool-btn {
    justify-content: center;
}

/* Settings */
.settings-group,
.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-group label,
.color-picker-group label {
    font-size: 12px;
    color: #b0b0b0;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #3d3d3d;
    outline: none;
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #0066cc;
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #0066cc;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

input[type="color"] {
    width: 100%;
    height: 30px;
    border: 1px solid #4d4d4d;
    background: #3d3d3d;
    cursor: pointer;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    padding: 20px;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    /* Dark background to contrast with canvas */
    background-color: #1e1e1e;
}

#mainCanvas {
    display: block;
    cursor: crosshair;
    /* Checkered background pattern to show transparency */
    background-image: 
        linear-gradient(45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(-45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d0d0d0 75%),
        linear-gradient(-45deg, transparent 75%, #d0d0d0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #ffffff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Layers Panel */
.layers-panel {
    display: flex;
    flex-direction: column-reverse;
    gap: 5px;
    margin-bottom: 10px;
    max-height: 300px;
    overflow-y: auto;
    background: #2d2d2d;
    padding: 5px;
    border-radius: 4px;
}

.layer-item {
    background: #3d3d3d;
    padding: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-item:hover {
    background: #4d4d4d;
}

.layer-item.active {
    background: #0066cc;
    border: 1px solid #0077ee;
}

.layer-visibility {
    cursor: pointer;
}

.layer-name {
    flex: 1;
    font-size: 13px;
}

.layer-opacity {
    font-size: 11px;
    color: #888;
    margin-left: 5px;
    cursor: pointer;
}

.layer-opacity:hover {
    color: #aaa;
}

.layer-duration {
    font-size: 11px;
    color: #888;
    margin-left: 5px;
    cursor: pointer;
}

.layer-duration:hover {
    color: #aaa;
}

.layer-duration-input {
    width: 60px;
    padding: 2px 4px;
    background: #2d2d2d;
    border: 1px solid #4d4d4d;
    color: #e0e0e0;
    border-radius: 3px;
    font-size: 11px;
}

.layer-delete {
    background: #d32f2f;
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.layer-delete:hover {
    background: #f44336;
}

.layer-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.layer-controls .tool-btn {
    flex: 1;
    font-size: 11px;
    padding: 6px 8px;
}

/* Transform and Effects */
.transform-controls,
.effects-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.transform-controls .tool-btn,
.effects-panel .tool-btn {
    width: 100%;
    justify-content: center;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #2d2d2d;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    min-width: 300px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #e0e0e0;
    font-size: 18px;
}

.modal-content label {
    display: block;
    margin-bottom: 15px;
    color: #b0b0b0;
    font-size: 14px;
}

.modal-content input[type="number"],
.modal-content input[type="color"] {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    background: #3d3d3d;
    border: 1px solid #4d4d4d;
    color: #e0e0e0;
    border-radius: 4px;
}

.modal-content input[type="checkbox"] {
    margin-right: 8px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.modal-buttons button:first-child {
    background: #0066cc;
    color: white;
}

.modal-buttons button:first-child:hover {
    background: #0077ee;
}

.modal-buttons button:last-child {
    background: #4d4d4d;
    color: #e0e0e0;
}

.modal-buttons button:last-child:hover {
    background: #5d5d5d;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #2d2d2d;
}

::-webkit-scrollbar-thumb {
    background: #4d4d4d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5d5d5d;
}

/* Metadata Table - Property Grid Style */
.metadata-table {
    width: 100%;
    font-size: 12px;
}

#metadataTable {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #3d3d3d;
}

#metadataTable tr {
    border-bottom: 1px solid #3d3d3d;
}

#metadataTable tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

#metadataTable tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

#metadataTable td {
    padding: 3px 6px;
    vertical-align: middle;
    line-height: 1.4;
}

#metadataTable td:first-child {
    width: 40%;
    font-size: 11px;
    color: #a0a0a0;
    font-weight: 500;
    padding-right: 8px;
    border-right: 1px solid #3d3d3d;
    background: rgba(0, 0, 0, 0.1);
}

.metadata-field-name {
    font-size: 11px;
    color: #a0a0a0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 2px 0;
}

.metadata-delete-btn {
    background: transparent;
    border: none;
    color: #d32f2f;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

#metadataTable tr:hover .metadata-delete-btn {
    opacity: 1;
}

.metadata-delete-btn:hover {
    background: #d32f2f;
    color: white;
}

.metadata-input {
    width: 100%;
    padding: 3px 5px;
    background: transparent;
    border: 1px solid transparent;
    color: #e0e0e0;
    border-radius: 2px;
    font-size: 11px;
    font-family: inherit;
    transition: all 0.2s;
}

.metadata-input:hover {
    background: #3d3d3d;
    border-color: #4d4d4d;
}

.metadata-input:focus {
    outline: none;
    background: #3d3d3d;
    border-color: #0066cc;
}

textarea.metadata-input {
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
}

/* Metadata Group Headers */
.metadata-group-header td {
    background: #1a1a1a !important;
    color: #888 !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    padding: 6px 8px !important;
    border-top: 1px solid #3d3d3d;
    border-bottom: 1px solid #3d3d3d;
}

.metadata-group-header:first-child td {
    border-top: none;
}
